:root {
  --green: #22c55e;
  --green-dark: #16a34a;
  --green-soft: #86efac;
  --blue: #3b82f6;
  --blue-soft: #93c5fd;
  --bg-page: #e8eaed;
  --bg-card: #ffffff;
  --text: #111827;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

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

a {
  color: inherit;
  text-decoration: none;
}

.hidden {
  display: none !important;
}

/* —— 顶栏 —— */
.app-header {
  background: var(--green);
  color: #fff;
  padding: calc(10px + var(--safe-top)) 16px 12px;
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  text-align: center;
}

.app-header--sub {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.app-header__back {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 0.95rem;
  padding: 6px 0;
  cursor: pointer;
}

/* —— 登录页 —— */
.login-body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.login-main {
  flex: 1;
  padding: 24px 20px 32px;
}

.login-card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 28px 22px;
  max-width: 400px;
  margin: 0 auto;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 1.35rem;
  font-weight: 700;
}

.login-card p.sub {
  margin: 0 0 24px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  background: #fafafa;
}

.field input:focus {
  outline: 2px solid var(--green-soft);
  outline-offset: 0;
  border-color: var(--green);
  background: #fff;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 18px;
  margin: 18px 0 22px;
  flex-wrap: wrap;
}

.check-row label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
}

.btn-primary {
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 1.05rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(180deg, var(--green) 0%, var(--green-dark) 100%);
  cursor: pointer;
}

.btn-primary:active {
  transform: scale(0.99);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.msg {
  margin-top: 14px;
  font-size: 0.88rem;
  min-height: 1.2em;
  color: #dc2626;
}

.msg--ok {
  color: var(--green-dark);
}

.msg--err {
  color: #dc2626;
}

/* —— 明细查询 —— */
.detail-query-page {
  max-width: 100%;
}

.detail-filters {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.detail-filters__row {
  display: flex;
  flex-direction: row;
  gap: 10px;
  align-items: stretch;
}

.detail-filters__field {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.detail-filters__row--dates .detail-filters__field--date {
  flex: 0 1 9.75rem;
  max-width: 10.5rem;
  min-width: 0;
}

.detail-filters__label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.detail-filters__input {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 0.95rem;
  background: #fff;
}

.detail-filters__input--date {
  min-height: 48px;
  color-scheme: light;
}

.detail-query__submit {
  width: 100%;
  margin-top: 16px;
}

.detail-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
  align-items: baseline;
  margin-bottom: 14px;
  padding: 12px 14px;
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
  border: 1px solid #bbf7d0;
  border-radius: 12px;
  font-size: 0.92rem;
  color: var(--text);
}

.detail-summary__item strong {
  font-size: 1.05rem;
  font-weight: 700;
  color: #166534;
}

.detail-table-wrap {
  margin-top: 16px;
}

.detail-table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.detail-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.detail-table th,
.detail-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detail-table th {
  position: sticky;
  top: 0;
  background: #f3f4f6;
  font-weight: 600;
  color: var(--text-muted);
  z-index: 1;
}

.detail-table tbody tr:last-child td {
  border-bottom: none;
}

.detail-empty,
.detail-truncated {
  margin: 12px 0 0;
  font-size: 0.88rem;
  color: var(--text-muted);
  text-align: center;
}

.detail-truncated {
  color: #b45309;
}

/* —— 首页本月薪资提示 —— */
.home-salary-banner {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: linear-gradient(120deg, #eff6ff 0%, #e0f2fe 55%, #f0f9ff 100%);
  border: 1px solid #bfdbfe;
  font-size: 0.92rem;
  color: #1e3a5f;
  line-height: 1.45;
}

.home-salary-banner__inner strong {
  font-size: 1.08rem;
  font-weight: 700;
  color: #1d4ed8;
  letter-spacing: 0.02em;
}

/* —— App 壳 —— */
.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(64px + var(--safe-bottom));
}

.app-content {
  flex: 1;
  background: var(--bg-card);
  margin: 12px 12px 0;
  border-radius: 16px 16px 0 0;
  padding: 20px 16px 24px;
  min-height: 200px;
}

.grid-menu {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px 12px;
  max-width: 420px;
  margin: 0 auto;
}

.grid-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--text);
}

.grid-item:active .grid-item__icon {
  transform: scale(0.96);
}

.grid-item__icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease;
}

.grid-item__icon--green {
  background: var(--green);
  color: #fff;
}

.grid-item__icon--blue {
  background: var(--blue);
  color: #fff;
}

.grid-item__icon--mint {
  background: var(--green-soft);
  color: #14532d;
}

.grid-item__label {
  font-size: 0.82rem;
  text-align: center;
  line-height: 1.25;
}

.icon-svg {
  width: 30px;
  height: 30px;
}

/* —— 底栏 —— */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(56px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: flex-start;
  padding-top: 8px;
  z-index: 50;
}

.tabbar button {
  flex: 1;
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 0;
}

.tabbar button svg {
  width: 22px;
  height: 22px;
}

.tabbar button.is-active {
  color: var(--green);
}

.tabbar button.is-active svg {
  stroke: var(--green);
  fill: none;
}

/* —— 扫描 / 占位 —— */
#view-scan.app-content {
  position: relative;
  z-index: 20;
  padding-bottom: max(28px, calc(72px + var(--safe-bottom)));
}

.scan-panel {
  max-width: 440px;
  margin: 0 auto;
}

.video-wrap {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  background: #111;
  aspect-ratio: 3 / 4;
  max-height: 62dvh;
}

.video-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.scan-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}

.scan-manual {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  position: relative;
  z-index: 30;
}

.scan-manual__label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.scan-manual__input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  background: #fafafa;
  margin-bottom: 12px;
}

.scan-manual__input:focus {
  outline: 2px solid var(--green-soft);
  outline-offset: 0;
  border-color: var(--green);
  background: #fff;
}

.scan-manual__submit {
  width: 100%;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* —— 扫码结果底部弹层 —— */
.scan-result-sheet {
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
  visibility: hidden;
}

.scan-result-sheet.is-open {
  pointer-events: auto;
  visibility: visible;
}

.scan-result-sheet__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.scan-result-sheet.is-open .scan-result-sheet__backdrop {
  opacity: 1;
}

.scan-result-sheet__panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 78vh;
  background: var(--bg-card);
  border-radius: 18px 18px 0 0;
  padding: 10px 18px calc(18px + var(--safe-bottom));
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  overflow-y: auto;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.12);
}

.scan-result-sheet.is-open .scan-result-sheet__panel {
  transform: translateY(0);
}

.scan-result-sheet__grab {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin: 0 auto 12px;
}

.scan-result-sheet__title {
  margin: 0 0 8px;
  font-size: 1.05rem;
  font-weight: 700;
  text-align: center;
}

.scan-result-sheet__code {
  margin: 0 0 14px;
  font-size: 0.88rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.4;
}

.scan-result-sheet__code.hidden {
  display: none;
  margin: 0;
  height: 0;
  overflow: hidden;
}

.scan-result-sheet__list {
  margin: 0 0 16px;
  padding: 0;
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 8px 12px;
  font-size: 0.9rem;
}

.scan-result-sheet__list.hidden {
  display: none;
}

.scan-result-gongxu {
  margin: 0 0 16px;
  max-height: 48vh;
  overflow-y: auto;
  font-size: 0.88rem;
}

.scan-result-gongxu.hidden {
  display: none;
}

.scan-result-gongxu__sub {
  margin: 0 0 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.scan-result-gongxu__meta-wrap {
  overflow-x: auto;
  margin-bottom: 8px;
}

.scan-result-gongxu__meta {
  width: 100%;
  min-width: min(100%, 520px);
  border-collapse: collapse;
  font-size: 0.74rem;
  table-layout: fixed;
}

.scan-result-gongxu__meta th,
.scan-result-gongxu__meta td {
  border: 1px solid var(--border);
  padding: 4px 6px;
  text-align: center;
  word-break: break-all;
  line-height: 1.25;
}

.scan-result-gongxu__meta th {
  background: #f3f4f6;
  color: var(--text-muted);
  font-weight: 600;
}

.scan-result-gongxu__feedback {
  min-height: 1.2em;
  margin: 6px 0 8px;
  font-size: 0.86rem;
}

.scan-result-gongxu__feedback--ok {
  color: #166534;
  font-weight: 600;
}

.scan-result-gongxu__feedback--err {
  color: #b91c1c;
}

.scan-result-gongxu__table--ops .scan-result-gongxu__th-check {
  width: 2.25rem;
}

.scan-result-gongxu__table--ops .scan-result-gongxu__chk {
  text-align: center;
  vertical-align: middle;
}

.scan-result-gongxu__table--ops .scan-result-gongxu__chk input {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--green);
  cursor: pointer;
}

.scan-result-gongxu__table--ops .scan-result-gongxu__chk input:disabled {
  cursor: default;
  opacity: 0.85;
}

.scan-result-gongxu__submit {
  width: 100%;
  margin-top: 12px;
}

.scan-result-gongxu__table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}

.scan-result-gongxu__table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 0.74rem;
}

.scan-result-gongxu__table th,
.scan-result-gongxu__table td {
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.scan-result-gongxu__table th {
  background: #f3f4f6;
  font-weight: 600;
  color: var(--text-muted);
}

.scan-result-sheet__dt {
  margin: 0;
  color: var(--text-muted);
  font-weight: 500;
}

.scan-result-sheet__dd {
  margin: 0;
  color: var(--text);
  word-break: break-all;
}

.scan-result-sheet__close {
  width: 100%;
}

.btn-secondary {
  flex: 1;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 12px;
  padding: 12px;
  font-size: 0.95rem;
  cursor: pointer;
}

.btn-danger-outline {
  border-color: #fecaca;
  color: #b91c1c;
}

.stub-page {
  text-align: center;
  padding: 32px 12px;
  color: var(--text-muted);
}

.stub-page h2 {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 1.1rem;
}

.mine-page {
  max-width: 400px;
  margin: 0 auto;
}

/* 避免固定底栏挡住「退出登录」点击（部分机型安全区/窄屏重叠） */
.mine-page .settings-actions {
  position: relative;
  z-index: 60;
  margin-bottom: 12px;
  padding-bottom: 4px;
}

.mine-row {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

.mine-row span {
  color: var(--text-muted);
  display: block;
  font-size: 0.8rem;
  margin-bottom: 4px;
}

.settings-page {
  max-width: 400px;
  margin: 0 auto;
}

.settings-actions {
  margin-top: 24px;
}

.toolbar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.toolbar-row .app-header__back {
  color: var(--green);
}

.toolbar-row h2 {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 600;
}
