:root {
  --xh-bg: #f6f8f9;
  --xh-panel: #ffffff;
  --xh-border: #e8e8e8;
  --xh-text: #1a1a1a;
  --xh-muted: #666;
  --xh-green: #00c17c;
  --xh-green-2: #00a86a;
  --xh-red: #e5484d;
  --xh-orange: #d97706;
  --xh-sider-w: 228px;
  --xh-radius: 8px;
  --xh-font: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --xh-shadow: 0 8px 28px rgba(0, 0, 0, .06);
}
* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body { font-family: var(--xh-font); background: var(--xh-bg); color: var(--xh-text); font-size: 13px; }
a { color: var(--xh-green); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  position: relative;
  background:
    radial-gradient(900px 520px at 18% 12%, rgba(0, 193, 124, .22), transparent 58%),
    linear-gradient(145deg, #e8f5ef 0%, #f3faf6 42%, #eef6f2 100%);
}
.login-layout {
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 22px;
  position: relative;
  z-index: 1;
}
.login-box {
  background: #fff;
  border-radius: 14px;
  padding: 36px 32px 28px;
  box-shadow: 0 18px 48px rgba(0,0,0,.16);
}
.login-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.login-logo .mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(145deg, #1aa88a, #0d7a6a);
}
.login-brand { font-size: 20px; font-weight: 700; color: #0f766e; }
.login-title { margin: 0 0 6px; font-size: 26px; }
.login-sub { color: #6b7280; margin: 0 0 26px; }
.login-field { margin-bottom: 16px; }
.login-field label { display: block; margin-bottom: 7px; font-weight: 500; }
.login-field input {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid #d1d5db; border-radius: 8px; background: #f8fafb;
}
.login-submit { width: 100%; height: 42px; margin-top: 6px; letter-spacing: .12em; }
.login-links { margin-top: 14px; text-align: center; }
.login-roles { background: #fff; border-radius: 14px; padding: 22px; box-shadow: var(--xh-shadow); }
.login-roles h2 { margin: 0 0 6px; font-size: 16px; }
.login-roles-tip { color: var(--xh-muted); margin: 0 0 14px; }
.login-role-group-title { font-size: 12px; color: #888; margin: 10px 0 8px; }
.login-role-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.login-role-card {
  text-align: left; border: 1px solid var(--xh-border); background: #f9fbfa;
  border-radius: 10px; padding: 10px;
}
.login-role-card.active { border-color: var(--xh-green); background: #f0fdf8; }
.login-role-card strong { display: block; }
.login-role-cred { color: #0f766e; font-size: 12px; }
.login-role-card em { display: block; color: #888; font-style: normal; font-size: 12px; }

.layout { display: flex; min-height: 100vh; }
.layout.sider-off .sider { display: none; }
.sider {
  width: var(--xh-sider-w); background: #fff; border-right: 1px solid var(--xh-border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow: auto;
  z-index: 8;
}
.sider-brand { padding: 16px 12px 10px; font-weight: 700; color: #0f766e; display: flex; justify-content: space-between; align-items: center; }
.sider-toggle, .sider-open { height: 32px; min-width: 32px; padding: 0 10px; }
.nav-group { padding: 4px 10px 2px; }
.nav-label {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: #889; padding: 8px 8px 4px; border: 0; background: transparent; text-align: left;
}
.nav-label em { font-style: normal; color: #bbb; }
.nav-item {
  width: 100%; text-align: left; border: 0; background: transparent;
  padding: 7px 10px; border-radius: 8px; color: #333;
}
.nav-item.active { background: rgba(0,193,124,.12); color: #0d7a6a; font-weight: 600; }
.sider-foot { margin-top: auto; padding: 14px; border-top: 1px solid var(--xh-border); color: #666; }
.sider-foot .site-foot { display: block; margin-top: 10px; font-size: 12px; color: #888; }

.main { flex: 1; padding: 18px 22px 40px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 10px; }
.crumb { color: #888; font-size: 12px; }
.topbar h1 { margin: 4px 0 0; font-size: 20px; }
.topbar-right { display: flex; gap: 8px; }
.search { height: 36px; padding: 0 10px; border: 1px solid var(--xh-border); border-radius: 8px; min-width: 220px; }
.page-guide { color: #667; margin: 0 0 14px; line-height: 1.6; }
.drill-bar { background: #f0faf5; border: 1px solid #d8efe4; border-radius: 8px; padding: 8px 12px; }
.field-hint { display: block; color: #889; font-size: 12px; font-weight: 400; margin: 2px 0 6px; }

.btn { border: 0; border-radius: 8px; height: 36px; padding: 0 14px; }
.btn-primary { background: var(--xh-green); color: #fff; }
.btn-ghost { background: #fff; border: 1px solid var(--xh-border); }
.link { background: none; border: 0; color: var(--xh-green); padding: 0 6px; }
.link.danger { color: var(--xh-red); }

.kpi-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.entry-wrap { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.entry-label { font-size: 12px; color: #667; margin-bottom: 8px; }
.entry-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.entry-card {
  text-align: left; border: 1px solid var(--xh-border); background: #fff;
  border-radius: 10px; padding: 12px 12px 10px;
}
.entry-card strong { display: block; font-size: 14px; }
.entry-card span { color: #888; font-size: 12px; }
.entry-card.personal { border-top: 3px solid #10b981; }
.entry-card.sales { border-top: 3px solid #38bdf8; }
.entry-card.buy { border-top: 3px solid #f59e0b; }
.form-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.form-tabs button {
  border: 1px solid var(--xh-border); background: #fff; border-radius: 8px;
  height: 32px; padding: 0 10px; color: #555;
}
.form-tabs button.active { background: rgba(0,193,124,.12); color: #0d7a6a; border-color: #9ee0c8; }
.wf-boxes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.wf-box {
  text-align: left; border: 1px solid var(--xh-border); background: #fff;
  border-radius: 10px; padding: 12px 14px;
}
.wf-box strong { display: block; font-size: 22px; color: #0f766e; }
.wf-box span { color: #667; font-size: 12px; }
.wf-box.active { border-color: #9ee0c8; background: #f0fdf8; box-shadow: 0 0 0 2px rgba(0,193,124,.12); }
.cal-month { font-size: 18px; min-width: 96px; text-align: center; }
.cal-grid {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px;
  background: #fff; border: 1px solid var(--xh-border); border-radius: 10px; padding: 12px;
}
.cal-head { text-align: center; color: #667; font-size: 12px; padding: 4px 0; }
.cal-cell {
  min-height: 64px; border: 1px solid var(--xh-border); border-radius: 8px;
  background: #f8fafb; text-align: left; padding: 8px;
}
.cal-cell em { display: block; font-style: normal; font-weight: 700; }
.cal-cell span { font-size: 12px; color: #667; }
.cal-cell.empty { visibility: hidden; }
.cal-cell.t-工作日 { background: #ecfdf5; border-color: #bbf7d0; }
.cal-cell.t-休息日 { background: #fff7ed; border-color: #fed7aa; }
.cal-cell.t-节假日 { background: #fef2f2; border-color: #fecaca; }
.cal-cell.t-none { background: #f3f4f6; }
.inv-filter { display: flex; gap: 10px; align-items: end; margin-bottom: 12px; flex-wrap: wrap; }
.inv-filter label { display: flex; flex-direction: column; gap: 4px; color: #555; }
.inv-filter input, .inv-filter select { height: 36px; border: 1px solid var(--xh-border); border-radius: 8px; padding: 0 10px; min-width: 180px; }
.photo-list { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.photo-chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--xh-border); border-radius: 8px; padding: 6px 8px; }
.photo-chip img { width: 36px; height: 36px; object-fit: cover; border-radius: 4px; }
.photo-upload { position: relative; overflow: hidden; }
.photo-upload input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.kpi { background: #fff; border: 1px solid var(--xh-border); border-radius: 10px; padding: 14px 16px; }
.kpi.clickable { cursor: pointer; }
.kpi.clickable:hover { border-color: var(--xh-green); box-shadow: 0 4px 14px rgba(0,161,106,.08); }
.kpi-label { color: #777; }
.kpi-hint { color: #9aa; font-size: 11px; margin-top: 6px; }
.kpi-value { font-size: 22px; font-weight: 700; margin-top: 6px; }
.kpi-value.pos, .pos { color: var(--xh-green-2); }
.kpi-value.neg, .neg { color: var(--xh-red); }
.card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.card { background: #fff; border: 1px solid var(--xh-border); border-radius: 10px; padding: 14px; }
.card h3 { margin: 0 0 10px; font-size: 14px; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid #f0f0f0; text-align: left; white-space: nowrap; }
th { background: #f3faf7; font-weight: 600; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; background: #eef2f3; }
.tag.ok { background: #dcfce7; color: #166534; }
.tag.warn { background: #fef3c7; color: #92400e; }
.tag.bad { background: #fee2e2; color: #991b1b; }
.empty { text-align: center; color: #999; padding: 20px; }
.pager { display: flex; gap: 8px; align-items: center; padding-top: 10px; color: #666; flex-wrap: wrap; }
.pager select, .pager-jump input { height: 32px; border: 1px solid var(--xh-border); border-radius: 6px; padding: 0 8px; }
.pager-jump input { width: 56px; }
.ops { white-space: nowrap; }

.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 180px 1fr 90px; gap: 8px; align-items: center; }
.bar-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #555; }
.bar-row i { display: block; height: 10px; background: #00c17c; border-radius: 99px; }
.bar-row i.pay { background: #38bdf8; }
.bar-row em { font-style: normal; text-align: right; }

.modal { position: fixed; inset: 0; background: rgba(15,23,42,.42); display: grid; place-items: center; z-index: 20; padding: 20px; }
.modal-box {
  background: #fff; width: min(920px, 100%); max-height: 92vh;
  border-radius: 16px; display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 24px 64px rgba(15,23,42,.22);
}
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 16px 20px 10px; border-bottom: 1px solid #f0f0f0; }
.modal-kicker { margin: 0; color: #889; font-size: 12px; }
.modal-box h2 { margin: 2px 0 0; font-size: 18px; }
.modal-x { width: 36px; height: 36px; border: 0; background: #f3f4f6; border-radius: 8px; font-size: 22px; line-height: 1; color: #555; }
.modal-body { padding: 14px 20px; overflow: auto; flex: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; color: #555; }
.form-grid label.wide { grid-column: 1 / -1; }
.form-grid label.bad input, .form-grid label.bad select, .form-grid label.bad textarea { border-color: #f3b4b4; background: #fff7f7; }
.field-label i { color: var(--xh-red); margin-left: 3px; font-style: normal; }
.field-err { color: var(--xh-red); font-size: 12px; }
.region-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.form-grid input, .form-grid select, .form-grid textarea {
  border: 1px solid var(--xh-border); border-radius: 8px; padding: 8px 10px; font: inherit; background: #fbfcfd;
}
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus {
  outline: 0; border-color: #7ed9b8; box-shadow: 0 0 0 3px rgba(0,193,124,.12); background: #fff;
}
.hours-box { margin-top: 16px; overflow: auto; }
.hours-box input { width: 100%; min-width: 64px; border: 1px solid var(--xh-border); border-radius: 6px; padding: 4px 6px; }
.hours-head { font-weight: 600; margin-bottom: 8px; color: #0f766e; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid #f0f0f0; background: #fafbfc; }
.wm {
  position: fixed; inset: -20%; pointer-events: none; z-index: 6; opacity: .045;
  display: flex; flex-wrap: wrap; transform: rotate(-18deg); overflow: hidden;
}
.wm span { width: 220px; padding: 48px 12px; font-size: 15px; color: #0f766e; }
.page-foot, .site-foot { color: #8a8f8a; font-size: 12px; }
.page-foot { margin-top: 28px; padding-top: 12px; border-top: 1px solid #eef1f0; }
.login-foot { margin-top: 18px; text-align: center; }

.toasts { position: fixed; right: 16px; top: 16px; z-index: 30; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #111827; color: #fff; padding: 8px 12px; border-radius: 8px; }
.toast.ok { background: #047857; }
.toast.err { background: #b91c1c; }

.click-row { cursor: pointer; }
.click-row:hover { background: #f3fbf7; }
.print-layer { position: fixed; inset: 0; z-index: 40; background: #f5f6f5; overflow: auto; }
.print-toolbar { display: flex; justify-content: space-between; align-items: center; padding: 12px 20px; background: #fff; border-bottom: 1px solid #e8eceb; }
.print-sheet { max-width: 760px; margin: 24px auto 40px; background: #fff; padding: 28px 32px; border: 1px solid #e8eceb; }
.print-sheet h1 { margin: 0 0 4px; font-size: 22px; color: #0f766e; }
.print-sub { color: #667; margin: 0 0 18px; }
.print-sheet table { width: 100%; border-collapse: collapse; }
.print-sheet th { text-align: left; width: 28%; color: #667; font-weight: 500; padding: 6px 8px; border-bottom: 1px solid #f0f0f0; }
.print-sheet td { padding: 6px 8px; border-bottom: 1px solid #f0f0f0; }
.print-items { margin-top: 16px; }
.print-items th { width: auto; background: #f7faf8; }
.print-foot { margin-top: 24px; color: #8a8f8a; font-size: 12px; }

@media print {
  .layout, .modal, .toasts, .wm, .print-toolbar, .login-page { display: none !important; }
  .print-layer { position: static; background: #fff; overflow: visible; }
  .print-sheet { border: 0; margin: 0; max-width: none; }
}

@media (max-width: 900px) {
  .login-layout, .kpi-grid, .card-grid, .form-grid, .entry-wrap, .wf-boxes, .region-row { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 1fr; }
  .layout.sider-off .sider { display: none; }
  .layout:not(.sider-off) .sider {
    display: flex; position: fixed; z-index: 16; box-shadow: 12px 0 32px rgba(0,0,0,.12);
  }
}
