* { box-sizing: border-box; }
body { margin: 0; font-family: "Microsoft YaHei", Arial, sans-serif; color: #243040; background: #f4f6f8; -webkit-text-size-adjust: 100%; }
button, input, select { font: inherit; }
button { border: 0; background: #1769aa; color: white; padding: 9px 16px; border-radius: 6px; cursor: pointer; min-height: 38px; }
button.secondary { background: #eef2f5; color: #243040; }
button.danger { background: #b93434; }
button.tiny { min-height: 28px; padding: 4px 8px; font-size: 12px; }
button:hover { filter: brightness(0.96); }
input, select { width: 100%; border: 1px solid #cfd7df; border-radius: 6px; padding: 9px 10px; background: white; min-height: 38px; }
label { display: grid; gap: 6px; color: #445064; font-size: 14px; }
h1, h2, h3 { margin: 0; }
table { width: 100%; border-collapse: collapse; background: white; }
th, td { border-bottom: 1px solid #e6ebf0; text-align: left; padding: 10px; font-size: 14px; }
th { color: #526070; background: #f8fafc; }
tr:hover td { background: #fbfdff; }
.hidden { display: none !important; }
.muted { color: #738095; }
.error { color: #b93434; min-height: 22px; }
.message { color: #1769aa; min-height: 22px; }
.money { color: #10243d; font-weight: 800; }
.money.income { color: #127a3a; }
.money.expense { color: #b86b00; }
.money.profit { color: #1769aa; }
.money.loss { color: #b93434; }
.status-pill { display: inline-flex; align-items: center; min-height: 24px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.status-pill.normal { background: #e8f7ef; color: #127a3a; }
.status-pill.void { background: #fff1f1; color: #b93434; }
.status-pill.locked { background: #e7f0fb; color: #1769aa; }
.login-shell { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #f4f6f8, #e7edf3); }
.login-box { width: 360px; background: white; border: 1px solid #e2e7ed; padding: 28px; border-radius: 8px; box-shadow: 0 16px 40px rgba(20, 40, 70, .08); display: grid; gap: 16px; }
.app { min-height: 100vh; display: grid; grid-template-columns: 210px 1fr; }
.sidebar { background: #1f3147; color: white; padding: 18px 14px; display: flex; flex-direction: column; gap: 8px; }
.brand { font-weight: 700; font-size: 20px; padding: 10px 8px 18px; }
.nav { width: 100%; text-align: left; background: transparent; border-radius: 6px; color: #dce6f0; }
.nav.active, .nav:hover { background: #314963; color: white; }
.main { min-width: 0; }
.topbar { height: 62px; background: white; border-bottom: 1px solid #e1e7ed; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.tag { display: inline-block; margin-left: 8px; padding: 3px 8px; background: #e7f0fb; color: #1769aa; border-radius: 999px; font-size: 12px; }
.page { padding: 24px; display: grid; gap: 18px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 16px; }
.stat, .panel { background: white; border: 1px solid #e2e7ed; border-radius: 8px; padding: 18px; }
.panel { overflow-x: auto; }
.stat span { display: block; color: #66758a; }
.stat b { display: block; font-size: 30px; margin-top: 8px; color: #10243d; }
.grid.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
#supplierForm, #productForm, #storeForm { display: grid; align-content: start; gap: 14px; }
.rank { display: grid; gap: 10px; margin-top: 14px; }
.rank-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 8px 0; border-bottom: 1px solid #eef2f5; }
.chart-rank { gap: 14px; }
.dash-bar-row { display: grid; gap: 7px; }
.dash-bar-head { display: flex; justify-content: space-between; gap: 12px; color: #526070; font-size: 14px; }
.dash-bar-head b { color: #10243d; }
.dash-bar-track { height: 12px; background: #edf2f7; border-radius: 999px; overflow: hidden; }
.dash-bar { height: 100%; background: linear-gradient(90deg, #1769aa, #35a0d8); border-radius: 999px; }
.form-panel { display: grid; gap: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.section-head, .actions, .export-line { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.items { display: grid; gap: 10px; }
.item-row { display: grid; grid-template-columns: 2fr 1fr 80px; gap: 10px; align-items: end; }
.total-line { text-align: right; font-size: 18px; }
.file-label { border: 1px dashed #b8c5d2; padding: 14px; border-radius: 8px; }
.existing-photos { border: 1px solid #e2e7ed; border-radius: 8px; padding: 14px; background: #fbfcfd; }
.existing-photos h4 { margin: 0 0 12px; }
.photo-card { display: grid; gap: 8px; width: 150px; }
.photo-card button { width: 100%; padding: 7px 10px; }
.filters, .export-line { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.export-line { grid-template-columns: 220px 180px 1fr; justify-content: start; }
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(20, 32, 46, .45); display: grid; place-items: center; padding: 24px; }
#photoPreviewModal { z-index: 30; }
.modal-body { width: min(820px, 96vw); max-height: 88vh; overflow: auto; background: white; border-radius: 8px; padding: 22px; position: relative; }
.close { position: absolute; top: 12px; right: 12px; background: #eef2f5; color: #243040; }
.detail-modal-body { overflow: hidden; display: flex; flex-direction: column; gap: 14px; }
#detailContent { min-height: 0; display: flex; flex-direction: column; gap: 14px; }
.detail-meta { flex: 0 0 auto; display: grid; grid-template-columns: 150px 1fr 140px; gap: 10px; padding-right: 48px; }
.detail-meta div { min-height: 54px; padding: 9px 12px; border: 1px solid #e2e7ed; border-radius: 6px; background: #fbfcfd; }
.detail-meta span { display: block; color: #66758a; font-size: 12px; line-height: 1.3; }
.detail-meta b { display: block; margin-top: 5px; color: #10243d; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail-table-wrap { flex: 1 1 auto; min-height: 180px; max-height: 52vh; overflow: auto; border: 1px solid #dfe7ef; border-radius: 8px; background: white; box-shadow: inset 0 1px 0 rgba(255,255,255,.8); }
.detail-table { min-width: 0; table-layout: fixed; }
.detail-table thead th { position: sticky; top: 0; z-index: 1; background: #eef4fb; color: #12314f; font-size: 13px; }
.detail-product-col { width: 70%; }
.detail-money-col { width: 30%; }
.detail-table th, .detail-table td { height: 38px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.detail-table tbody tr:nth-child(even) td { background: #fbfdff; }
.detail-table tbody tr:hover td { background: #f3f8fc; }
.detail-table th:first-child, .detail-table td:first-child { padding-left: 14px; }
.detail-table th:last-child, .detail-table td:last-child { text-align: right; padding-right: 18px; }
.detail-table td:last-child { color: #8a4b00; font-weight: 800; font-variant-numeric: tabular-nums; }
.detail-photos { flex: 0 0 auto; }
.detail-photos h4 { margin: 0; }
.photos { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.photos img { width: 150px; height: 110px; object-fit: cover; border: 1px solid #e2e7ed; border-radius: 6px; }
.photo-preview-btn { min-height: 0; padding: 0; border: 0; background: transparent; color: inherit; border-radius: 6px; }
.photo-preview-btn:hover { filter: none; }
.photo-preview-btn:hover img { border-color: #1769aa; box-shadow: 0 0 0 2px rgba(23, 105, 170, .12); }
.photo-preview-modal { width: min(960px, 96vw); max-height: 92vh; display: grid; gap: 14px; overflow: hidden; }
.photo-preview-modal img { width: 100%; max-height: calc(92vh - 110px); object-fit: contain; border-radius: 6px; background: #f4f6f8; }
.photo-preview-actions { display: flex; justify-content: flex-end; }
.download-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 38px; padding: 9px 16px; border-radius: 6px; background: #1769aa; color: white; text-decoration: none; }
.user-manage { display: grid; gap: 14px; }
.user-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: end; }
.field-title { display: block; color: #445064; font-size: 14px; margin-bottom: 6px; }
.checks { min-height: 38px; display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; padding: 8px 10px; border: 1px solid #cfd7df; border-radius: 6px; background: white; }
.checks label { display: inline-flex; grid-template-columns: none; align-items: center; gap: 5px; font-size: 14px; }
.checks input { width: auto; min-height: auto; }
.mini-list { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 4px; }
.mini-list span { display: inline-flex; align-items: center; gap: 6px; border: 1px solid #e2e7ed; border-radius: 6px; padding: 6px; }
.product-result { max-height: 260px; overflow: auto; border: 1px solid #e2e7ed; border-radius: 6px; }
.product-result table { min-width: 0; }
.product-result th, .product-result td { padding: 8px 10px; }
.product-manage { display: grid; gap: 12px; }
.product-filters { grid-template-columns: minmax(180px, 260px) minmax(240px, 1fr); margin-bottom: 0; }
.profit-panel { display: grid; gap: 16px; }
.profit-form { display: grid; grid-template-columns: 220px minmax(220px, 1fr) 150px; gap: 12px; align-items: end; }
.profit-summary { display: grid; grid-template-columns: repeat(4, minmax(160px, 1fr)); gap: 12px; }
.statement-summary { grid-template-columns: repeat(3, minmax(160px, 1fr)); }
.statement-detail-wrap { max-height: 560px; overflow: auto; border: 1px solid #d8e1ea; border-radius: 8px; background: white; }
.statement-detail-table { min-width: 900px; border-collapse: separate; border-spacing: 0; }
.statement-detail-table th, .statement-detail-table td { border-right: 1px solid #e1e7ed; border-bottom: 1px solid #e1e7ed; }
.statement-detail-table th:last-child, .statement-detail-table td:last-child { border-right: 0; }
.statement-detail-table thead th { position: sticky; top: 0; z-index: 1; background: #eef4fb; color: #12314f; box-shadow: 0 1px 0 #d8e1ea; }
.statement-detail-table tbody tr:nth-child(even) td { background: #fbfdff; }
.statement-detail-table tbody tr:hover td { background: #f3f8fc; }
.statement-detail-table .amount-cell { text-align: right; padding-right: 18px; white-space: nowrap; }
.profit-formula { color: #1769aa; background: #eef7ff; border: 1px solid #cfe5f8; border-radius: 6px; padding: 10px 12px; }
.setup-guide { color: #7a4a00; background: #fff7e6; border: 1px solid #f2d28b; border-radius: 6px; padding: 12px 14px; }
.setup-guide b { color: #5d3900; }
.lock-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: #526070; background: #f8fafc; border: 1px solid #e2e7ed; border-radius: 6px; padding: 10px 12px; }
.password-box { display: grid; gap: 14px; max-width: 420px; }
.fixed-cost-form { display: grid; gap: 16px; }
.cost-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.tab-buttons { display: flex; gap: 10px; }
.salary-panel { display: grid; gap: 16px; }
.sub-panel { display: grid; align-content: start; gap: 12px; border: 1px solid #e2e7ed; border-radius: 8px; padding: 14px; background: #fbfcfd; }
.salary-settings-form { max-height: 520px; overflow-y: auto; padding-right: 12px; }
.salary-param-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.salary-tier-editor { display: grid; gap: 8px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-head h4 { margin: 0; color: #10243d; font-size: 15px; }
.salary-tier-wrap { overflow-x: auto; border: 1px solid #d8e1ea; border-radius: 6px; background: white; }
.salary-tier-wrap table { min-width: 480px; }
.salary-tier-wrap th, .salary-tier-wrap td { border-bottom: 1px solid #e2e7ed; }
.salary-tier-wrap tbody tr:last-child td { border-bottom: 0; }
.salary-tier-wrap input { width: 100%; min-width: 96px; padding: 7px 8px; }
.salary-table-wrap input { min-width: 86px; padding: 7px 8px; }
.bar-chart { display: grid; gap: 10px; margin-top: 14px; min-width: 360px; }
.bar-row { display: grid; grid-template-columns: 64px 1fr 90px; align-items: center; gap: 10px; }
.bar-row span { color: #526070; font-size: 13px; }
.bar-row b { text-align: right; font-size: 13px; }
.bar-track { height: 18px; background: #edf2f7; border-radius: 4px; overflow: hidden; }
.bar { height: 100%; background: #1769aa; border-radius: 4px; }
.bar.negative { background: #b93434; }
.compare-filters { grid-template-columns: minmax(160px, 1.2fr) 54px minmax(100px, .8fr) minmax(100px, .8fr) 54px minmax(100px, .8fr) minmax(100px, .8fr) 130px; align-items: end; }
.compare-label { display: grid; place-items: center; min-height: 38px; border-radius: 6px; background: #eef7ff; color: #1769aa; font-weight: 700; }
.compare-table { display: grid; gap: 12px; }
.compare-metric { background: white; border: 1px solid #e2e7ed; border-radius: 8px; padding: 14px; display: grid; gap: 10px; }
.compare-metric-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.compare-metric-title b { font-size: 18px; color: #10243d; }
.compare-metric-title em { font-style: normal; font-weight: 700; }
.compare-metric-title em.up { color: #127a3a; }
.compare-metric-title em.down { color: #b93434; }
.compare-side { display: grid; grid-template-columns: minmax(150px, 220px) 110px 1fr; align-items: center; gap: 10px; color: #526070; }
.compare-side strong { color: #10243d; text-align: right; }
.compare-track { height: 14px; background: #edf2f7; border-radius: 999px; overflow: hidden; }
.compare-fill { height: 100%; border-radius: 999px; }
.compare-fill.left { background: #1769aa; }
.compare-fill.right { background: #36a46f; }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 2; flex-direction: row; overflow-x: auto; }
  .brand { min-width: 120px; padding: 8px; }
  .nav { white-space: nowrap; }
  .grid.two, .stats, .form-grid, .filters, .user-form, .profit-form, .profit-summary, .cost-grid, .salary-param-grid, .compare-filters { grid-template-columns: 1fr; }
  .compare-side { grid-template-columns: 1fr; }
  .item-row { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  button, input, select { font-size: 16px; }
  body { background: white; }
  .login-shell { align-items: start; padding: 18px 12px; }
  .login-box { width: 100%; padding: 22px 18px; box-shadow: none; }
  .login-box h1 { font-size: 24px; line-height: 1.25; }
  .sidebar { padding: 10px 10px; gap: 6px; }
  .brand { min-width: 92px; font-size: 17px; padding: 9px 6px; }
  .nav { width: auto; min-width: max-content; padding: 9px 12px; }
  .topbar { height: auto; min-height: 54px; align-items: flex-start; gap: 8px; padding: 12px 14px; flex-direction: column; }
  .top-actions { width: 100%; align-items: stretch; flex-direction: column; }
  .tag { margin-left: 6px; }
  .page { padding: 14px 12px 22px; gap: 14px; }
  .page h2 { font-size: 22px; }
  .stat, .panel { border-radius: 6px; padding: 14px; }
  .stat b { font-size: 26px; }
  .section-head, .actions { align-items: stretch; }
  .section-head { gap: 12px; }
  .section-head button, .actions button { width: 100%; }
  .items { gap: 14px; }
  .item-row { border: 1px solid #e2e7ed; border-radius: 6px; padding: 12px; background: #fbfcfd; }
  .item-row .remove { width: 100%; }
  .total-line { font-size: 20px; padding-top: 2px; }
  .file-label { padding: 12px; }
  .filters, .export-line { grid-template-columns: 1fr; }
  .lock-line { align-items: stretch; flex-direction: column; }
  table { min-width: 620px; }
  th, td { padding: 9px 8px; white-space: nowrap; }
  td button { margin: 2px 0; padding: 8px 10px; }
  .modal { padding: 10px; align-items: start; }
  .modal-body { width: 100%; max-height: calc(100vh - 20px); padding: 18px 14px; }
  .detail-meta { grid-template-columns: 1fr; padding-right: 40px; }
  .photos img { width: 120px; height: 90px; }
  .photo-card { width: 120px; }
}
