/*
 * 统一视觉主题：在 styles.css、vant.css 和页面内联样式之后加载，
 * 负责管理端与员工端共用的配色、卡片、按钮，以及管理端的桌面布局与统计表格。
 */

:root {
  --bg: #f4f2ed;
  --surface: #ffffff;
  --surface-soft: #faf9f6;
  --ink: #1d2b25;
  --muted: #66716b;
  --line: rgba(29, 43, 37, 0.09);
  --accent: #c35f34;
  --accent-2: #2d6a5c;
  --late: #e02424;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(29, 43, 37, 0.04), 0 6px 20px rgba(29, 43, 37, 0.06);
  --font-body: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI",
    "Helvetica Neue", Arial, sans-serif;
  --font-display: var(--font-body);

  --van-primary-color: #2d6a5c;
  --van-text-color: #1d2b25;
  --van-text-color-2: #66716b;
  --van-border-color: rgba(29, 43, 37, 0.08);
  --van-cell-group-inset-radius: 16px;
  --van-cell-vertical-padding: 13px;
  --van-cell-font-size: 15px;
  --van-cell-label-font-size: 13px;
  --van-cell-label-color: #66716b;
  --van-field-label-color: #1d2b25;
  --van-button-default-font-size: 15px;
  --van-popup-round-radius: 22px;
  --van-tabbar-height: 56px;
  --van-tabbar-item-font-size: 11px;
  --van-tabbar-item-icon-size: 22px;
}

body,
body.admin-mobile,
body.employee-mobile {
  background: var(--bg);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  line-height: 1.45;
}

.muted {
  color: var(--muted);
}

/* ---------- 共用卡片 ---------- */

.mobile-card,
.employee-card,
.overview-chart-card,
.admin-calendar-card,
.schedule-card,
.employee-calendar-card,
.employee-stat,
.employee-work-stat,
.employee-status-card,
.employee-time-card,
.employee-map-card,
.employee-install-card,
.employee-photo-frame,
.mobile-stat {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  background-color: var(--surface);
}

.van-cell-group--inset.mobile-card,
.van-cell-group--inset.employee-card {
  border: 1px solid var(--line);
}

.overview-chart-card h3,
.popup-header h3 {
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.van-button {
  font-weight: 600;
}

.van-button--small {
  padding: 0 14px;
}

.van-tabbar {
  box-shadow: 0 -1px 0 var(--line), 0 -8px 24px rgba(29, 43, 37, 0.05);
}

.van-tabbar-item--active {
  font-weight: 700;
}

.van-popup--bottom {
  max-height: 92vh;
}

.mobile-empty,
.employee-empty {
  color: var(--muted);
  font-size: 0.92rem;
}

/* 日历格子：更轻的边框，选中态更清晰 */
.admin-calendar-day,
.employee-calendar-day {
  border-radius: 12px;
  border-color: var(--line);
  background: var(--surface);
  box-shadow: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.admin-calendar-day:hover,
.employee-calendar-day:hover {
  transform: none;
}

.admin-calendar-day.is-empty,
.employee-calendar-day.is-empty {
  background: transparent;
  border-color: transparent;
}

.admin-calendar-day.is-selected,
.employee-calendar-day.is-selected {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.admin-calendar-day .day-mark {
  font-weight: 600;
  color: var(--muted);
}

.admin-calendar-day.is-selected .day-mark {
  color: rgba(255, 255, 255, 0.82);
}

.history-late-dot.is-corner {
  box-shadow: 0 0 0 2px var(--surface);
}

.admin-calendar-day.is-selected .history-late-dot.is-corner {
  box-shadow: 0 0 0 2px var(--ink);
}

/* ---------- 员工端 ---------- */

.employee-hero {
  padding: 18px 16px 14px;
}

.employee-hero h1 {
  font-size: 1.5rem;
  letter-spacing: 0.01em;
}

.employee-user-tag {
  font-size: 0.92rem;
  padding: 5px 12px;
}

.employee-stat strong {
  font-size: 1.45rem;
  font-variant-numeric: tabular-nums;
}

/* ---------- 管理端：登录 ---------- */

.mobile-shell.is-login {
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 440px;
  padding: 24px 8px 64px;
}

/* ---------- 管理端：顶栏 ---------- */

.admin-sidebar {
  display: none;
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 12px;
}

.admin-topbar__brand,
.admin-sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.admin-topbar__brand .brand-logo,
.admin-sidebar__brand .brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  padding: 4px;
  background: var(--surface);
  box-shadow: var(--shadow);
  flex: none;
}

.admin-topbar__brand strong,
.admin-sidebar__brand strong {
  display: block;
  font-size: 1.05rem;
  line-height: 1.2;
}

.admin-topbar__brand span,
.admin-sidebar__brand span,
.admin-sidebar__user span {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
}

.admin-topbar__title {
  display: none;
  margin: 0;
  font-size: 1.5rem;
}

.admin-topbar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-icon-button,
.admin-link-button,
.admin-nav-item {
  transition: background 0.15s ease, color 0.15s ease;
}

.admin-icon-button:hover,
.admin-link-button:hover,
.admin-nav-item:hover {
  transform: none;
}

.admin-icon-button {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.admin-icon-button.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.admin-link-button {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 600;
}

.admin-tab-body {
  padding: 0 12px 16px;
}

/* ---------- 管理端：数字卡片 ---------- */

.stat-tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.stat-tile {
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  min-width: 0;
}

.stat-tile span {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
}

.stat-tile strong {
  display: block;
  margin-top: 6px;
  font-size: 1.45rem;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.stat-tile small {
  display: block;
  margin-top: 2px;
  font-size: 0.78rem;
  color: var(--muted);
}

.stat-tile.is-alert strong {
  color: var(--late);
}

.overview-grid {
  display: grid;
  gap: 12px;
}

.overview-pie::after {
  background: var(--surface);
}

.overview-day-card {
  background: var(--surface-soft);
  border-color: var(--line);
  border-radius: 12px;
}

/* ---------- 管理端：考勤统计 ---------- */

.stats-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 12px;
  margin-bottom: 12px;
}

.stats-toolbar__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.month-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.month-switch strong {
  min-width: 112px;
  text-align: center;
  font-size: 1.08rem;
  font-variant-numeric: tabular-nums;
}

.stats-filters {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 12px;
}

.stats-filters .van-cell-group {
  margin: 0;
  width: 100%;
}

.stats-table-card {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.stats-table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.stats-table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.stats-table th,
.stats-table td {
  padding: 12px 14px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.stats-table th {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-soft);
}

.stats-table .is-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.stats-table .is-sticky {
  position: sticky;
  left: 0;
  z-index: 1;
  box-shadow: 1px 0 0 var(--line);
}

.stats-table .is-link {
  width: 32px;
  color: rgba(29, 43, 37, 0.35);
  text-align: right;
}

.stats-table tbody tr {
  cursor: pointer;
}

.stats-table tbody tr:hover td {
  background: var(--surface-soft);
}

.stats-table tfoot td {
  background: var(--surface-soft);
  border-bottom: 0;
  font-weight: 600;
}

.stats-sub {
  display: block;
  margin-top: 2px;
  font-size: 0.76rem;
  font-weight: 400;
  color: var(--muted);
}

.stats-zero {
  color: rgba(29, 43, 37, 0.3);
}

.stats-hint {
  margin: 0;
  padding: 10px 14px 12px;
  font-size: 0.8rem;
  color: var(--muted);
}

/* ---------- 管理端：桌面布局 ---------- */

@media (min-width: 960px) {
  .mobile-shell.is-app {
    width: 100%;
    max-width: none;
    display: grid;
    grid-template-columns: 228px minmax(0, 1fr);
    padding-bottom: 0;
  }

  .admin-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 22px 14px 18px;
    background: var(--surface);
    border-right: 1px solid var(--line);
  }

  .admin-sidebar__brand {
    padding: 0 8px;
  }

  .admin-sidebar__nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
  }

  .admin-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 11px 12px;
    border-radius: 12px;
    background: transparent;
    color: var(--muted);
    font-size: 0.95rem;
    font-weight: 600;
    text-align: left;
  }

  .admin-nav-item:hover {
    background: rgba(29, 43, 37, 0.05);
    color: var(--ink);
  }

  .admin-nav-item.is-active {
    background: var(--ink);
    color: #fff;
  }

  .admin-nav-item em {
    margin-left: auto;
    min-width: 20px;
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 0.72rem;
    font-style: normal;
    text-align: center;
  }

  .admin-sidebar__user {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 14px 8px 0;
    border-top: 1px solid var(--line);
  }

  .admin-sidebar__user strong {
    display: block;
    font-size: 0.92rem;
  }

  .admin-main {
    width: 100%;
    max-width: 1240px;
    padding: 0 32px 48px;
  }

  .admin-topbar {
    padding: 28px 0 18px;
  }

  .admin-topbar__brand,
  .admin-topbar__actions {
    display: none;
  }

  .admin-topbar__title {
    display: block;
  }

  .admin-tab-body {
    padding: 0;
  }

  .admin-tabbar,
  .mobile-shell .van-tabbar__placeholder,
  .mobile-shell .van-tabbar {
    display: none;
  }

  .stat-tiles {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 16px;
  }

  .stat-tile {
    padding: 18px 20px;
  }

  .stat-tile strong {
    font-size: 1.7rem;
  }

  .stat-tile.is-wide {
    grid-column: span 2;
  }

  .overview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }

  .overview-chart-card {
    padding: 22px;
  }

  .overview-chart-card.is-full {
    grid-column: 1 / -1;
  }

  .overview-week {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }

  .overview-week .overview-day-card {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 8px;
  }

  .stats-filters {
    flex-direction: row;
    align-items: center;
  }

  .stats-filters .van-cell-group {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stats-filters .van-cell::after {
    display: none;
  }

  .stats-table th,
  .stats-table td {
    padding: 14px 18px;
  }

  .stats-table {
    font-size: 0.95rem;
  }

  /* 桌面端弹层：居中、限宽，避免铺满整屏 */
  .van-popup--bottom {
    left: 0;
    right: 0;
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
  }
}

/* 管理端内容区里的分组卡片与页面边缘对齐 */
.admin-tab-body .van-cell-group--inset {
  margin-left: 0;
  margin-right: 0;
}

.admin-tab-body .mobile-actions {
  margin-top: 0;
}

.admin-tab-body .mobile-section {
  padding-left: 0;
  padding-right: 0;
}

.mobile-stat strong {
  font-size: 1.35rem;
  font-variant-numeric: tabular-nums;
}

@media (min-width: 960px) {
  .van-popup .mobile-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.overview-legend-item strong {
  white-space: nowrap;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 959px) {
  .overview-pie {
    width: 112px;
    height: 112px;
    flex: 0 0 112px;
  }

  .overview-pie::after {
    inset: 20px;
  }
}

/* ---------- 管理端：薪资页 ---------- */

.payroll-table {
  min-width: 840px;
}

.payroll-warning {
  color: var(--late);
  font-weight: 700;
}

/* ---------- 管理端：桌面细节 ---------- */

@media (min-width: 960px) {
  .mobile-shell.is-login {
    width: 100%;
    min-height: 0;
    margin: 8vh auto;
    padding: 36px 32px 42px;
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid var(--line);
    border-radius: 28px;
    box-shadow: var(--shadow);
  }

  .van-popup--center {
    width: min(760px, calc(100vw - 64px)) !important;
    max-height: 88vh;
    overflow-y: auto;
  }

  .van-popup--center .van-cell-group--inset {
    margin-left: 0;
    margin-right: 0;
  }

  .stats-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
  }

  .stats-table .is-sticky {
    z-index: 3;
  }
}

/* 平板横屏：比手机宽，但还不到桌面侧栏断点 */
@media (min-width: 768px) and (max-width: 959px) {
  .mobile-shell.is-app {
    width: 100%;
    max-width: 760px;
  }

  .admin-tab-body {
    padding: 0 20px 24px;
  }
}

.admin-calendar-day__more {
  display: inline-block;
  font-size: 0.68rem;
  font-style: normal;
  color: var(--muted);
  line-height: 1;
}

.admin-calendar-day.is-selected .admin-calendar-day__more {
  color: rgba(255, 255, 255, 0.82);
}

.admin-sidebar__user {
  flex-wrap: wrap;
}

.admin-company-switch {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}

.admin-company-switch label {
  font-size: 0.72rem;
  color: var(--muted);
}

.admin-company-switch select {
  width: 100%;
  padding: 7px 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.82rem;
}
