:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --blue: #2563eb;
  --blue-soft: #eff6ff;
  --green: #16a34a;
  --orange: #f59e0b;
  --red: #dc2626;
  --purple: #7c3aed;
  --shadow: 0 14px 35px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 260px;
  background: #0f172a;
  color: white;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 14px;
  background: linear-gradient(135deg, #3b82f6, #06b6d4);
  display: grid; place-items: center; font-weight: 800;
}
.brand span { display: block; color: #94a3b8; font-size: 12px; margin-top: 4px; }
.nav { display: grid; gap: 8px; }
.nav-item {
  border: 0; text-align: left; color: #cbd5e1;
  background: transparent; border-radius: 12px; padding: 12px 14px;
}
.nav-item.active, .nav-item:hover { background: rgba(59,130,246,.22); color: white; }
.contract-box {
  margin-top: auto; border: 1px solid rgba(148,163,184,.25);
  border-radius: 16px; padding: 14px; color: #cbd5e1; font-size: 13px;
}
.contract-title { color: #fff; font-weight: 700; margin-bottom: 8px; }
.contract-box p { margin: 6px 0; }

.main { flex: 1; padding: 24px; overflow: auto; }
.topbar {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 18px;
}
.topbar h1 { margin: 0 0 8px; font-size: 26px; }
.topbar p { margin: 0; color: var(--muted); }
.user-switch {
  background: var(--panel); padding: 10px 12px; border-radius: 14px;
  box-shadow: var(--shadow); display: flex; align-items: center; gap: 10px;
}
.user-switch label { color: var(--muted); font-size: 13px; }
.user-switch select, .input, .select, .textarea {
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; background: #fff;
}
.page { display: none; }
.page.active { display: block; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }
.grid-6 { grid-template-columns: repeat(6, 1fr); }
.panel, .card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 18px; box-shadow: var(--shadow);
}
.panel { padding: 18px; }
.card { padding: 16px; }
.section-title { font-size: 18px; font-weight: 800; margin: 0 0 14px; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; color: var(--muted); }
.kpi { padding: 18px; }
.kpi span { color: var(--muted); font-size: 13px; }
.kpi strong { display: block; font-size: 28px; margin-top: 8px; }
.kpi.red strong { color: var(--red); }
.kpi.orange strong { color: var(--orange); }
.kpi.blue strong { color: var(--blue); }
.kpi.purple strong { color: var(--purple); }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.inline-form .input { min-width: 120px; }
.inline-form .select { min-width: 130px; }
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--text);
  border-radius: 11px; padding: 9px 13px; font-weight: 700;
}
.btn.primary { border-color: var(--blue); background: var(--blue); color: white; }
.btn.danger { border-color: #fecaca; background: #fff1f2; color: var(--red); }
.btn.ghost { background: var(--blue-soft); border-color: #bfdbfe; color: var(--blue); }

.employee-layout {
  max-width: 520px; margin: 0 auto; background: #e9eef8; padding: 14px;
  border-radius: 32px; border: 10px solid #111827; box-shadow: var(--shadow);
}
.phone-screen { background: #f8fafc; border-radius: 22px; padding: 16px; min-height: 760px; }
.phone-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.pill {
  display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 9px;
  font-size: 12px; font-weight: 700; background: var(--blue-soft); color: var(--blue);
}
.pill.green { background: #dcfce7; color: var(--green); }
.pill.orange { background: #ffedd5; color: #c2410c; }
.pill.red { background: #fee2e2; color: var(--red); }
.pill.purple { background: #ede9fe; color: var(--purple); }
.quick-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 12px 0; }
.entry-card { background: white; border: 1px solid var(--line); border-radius: 18px; padding: 14px; margin: 12px 0; }
.entry-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.field { display: grid; gap: 5px; }
.field label { font-size: 12px; color: var(--muted); }
.textarea { min-height: 72px; resize: vertical; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.chip {
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 9px;
  background: #fff; color: var(--muted); font-size: 12px;
}
.chip.active { background: var(--blue-soft); border-color: #bfdbfe; color: var(--blue); }
.bottom-bar {
  position: sticky; bottom: 0; background: rgba(255,255,255,.96); border: 1px solid var(--line);
  border-radius: 16px; padding: 10px; display: flex; justify-content: space-between; gap: 8px; align-items: center;
}

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); background: #f8fafc; }
td { font-size: 14px; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 14px; }
.split { display: grid; grid-template-columns: 1.6fr .9fr; gap: 16px; }
.detail-panel { position: sticky; top: 18px; }

.chart-box {
  height: 260px; display: flex; align-items: end; gap: 8px; padding: 12px 8px 28px;
  border-radius: 14px; background: #f8fafc; border: 1px dashed #cbd5e1;
  position: relative;
}
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}
.calendar-cell {
  min-height: 66px;
  border-radius: 14px;
  border: 1px solid var(--line);
  padding: 8px;
  display: grid;
  align-content: space-between;
  background: #f8fafc;
}
.calendar-cell strong { font-size: 16px; }
.calendar-cell span { font-size: 12px; color: var(--muted); }
.calendar-cell.confirmed { background: #dcfce7; border-color: #86efac; }
.calendar-cell.pending { background: #dbeafe; border-color: #93c5fd; }
.calendar-cell.missing { background: #fee2e2; border-color: #fecaca; }
.calendar-cell.rejected { background: #ffedd5; border-color: #fed7aa; }
.calendar-cell.offday { background: #f3f4f6; color: #9ca3af; }
.bar { flex: 1; background: linear-gradient(180deg, #60a5fa, #2563eb); border-radius: 8px 8px 0 0; min-width: 14px; position: relative; }
.bar span { position: absolute; bottom: -22px; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--muted); white-space: nowrap; }
.donut-list, .rank-list { display: grid; gap: 10px; }
.legend-row, .rank-row { display: grid; grid-template-columns: 120px 1fr 54px; gap: 10px; align-items: center; }
.progress { height: 10px; background: #e5e7eb; border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--blue); border-radius: 999px; }
.warning-card { border: 1px solid #fed7aa; background: #fff7ed; color: #9a3412; border-radius: 14px; padding: 12px; }
.admin-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 8px;
  box-shadow: var(--shadow);
}
.tab {
  border: 0;
  background: transparent;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 800;
  color: var(--muted);
}
.tab.active {
  background: var(--blue);
  color: #fff;
}
.admin-tab-panel { display: none; }
.admin-tab-panel.active { display: block; }

.toast {
  position: fixed; right: 24px; bottom: 24px; background: #111827; color: white;
  padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(10px); transition: .2s;
}
.toast.show { opacity: 1; transform: translateY(0); }

.modal-root { display: none; position: fixed; inset: 0; z-index: 1000; }
.modal-root.show { display: block; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .45); backdrop-filter: blur(2px); }
.modal-card {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow: auto;
  background: #fff; border: 1px solid var(--line); border-radius: 22px;
  box-shadow: var(--shadow); padding: 18px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.modal-head h3 { margin: 0; }
.modal-body p { line-height: 1.7; }

.mobile-install {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 900;
  display: none; align-items: center; justify-content: space-between; gap: 12px;
  background: #0f172a; color: #fff; border: 1px solid rgba(255,255,255,.12);
  border-radius: 18px; padding: 14px; box-shadow: 0 18px 40px rgba(15,23,42,.28);
}
.mobile-install.show { display: flex; }
.mobile-install p { margin: 4px 0 0; color: #cbd5e1; font-size: 12px; line-height: 1.5; }
.mobile-install-actions { display: flex; gap: 8px; flex-shrink: 0; }

@media (max-width: 1100px) {
  .sidebar { width: 220px; }
  .grid-6, .grid-5, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .split, .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { width: auto; min-height: auto; }
  .main { padding: 14px; }
  .topbar { display: grid; gap: 12px; }
  .grid-6, .grid-5, .grid-4, .grid-3 { grid-template-columns: 1fr; }
  .employee-layout { border: 0; border-radius: 18px; padding: 0; }
  .sidebar {
    position: sticky; top: 0; z-index: 50; padding: 12px; gap: 12px;
    border-bottom: 1px solid rgba(148,163,184,.2);
  }
  .brand { align-items: center; }
  .brand-mark { width: 34px; height: 34px; border-radius: 11px; }
  .brand span, .contract-box { display: none; }
  .nav { display: flex; overflow-x: auto; gap: 8px; padding-bottom: 2px; }
  .nav-item { white-space: nowrap; padding: 9px 12px; font-size: 14px; }
  .topbar h1 { font-size: 22px; }
  .user-switch { justify-content: space-between; width: 100%; }
  .user-switch select, .input, .select, .textarea { width: 100%; min-height: 42px; }
  .toolbar { display: grid; grid-template-columns: 1fr; }
  .toolbar .btn, .toolbar a.btn { width: 100%; text-align: center; }
  .phone-screen { min-height: calc(100vh - 190px); }
  .phone-header { display: grid; gap: 8px; }
  .form-row { grid-template-columns: 1fr; }
  .bottom-bar { flex-wrap: wrap; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .bottom-bar .btn { flex: 1; }
  .table-wrap { border-radius: 12px; }
  th, td { padding: 10px 8px; font-size: 13px; }
  .calendar-grid { grid-template-columns: repeat(4, 1fr); }
  .legend-row, .rank-row { grid-template-columns: 90px 1fr 48px; }
  .inline-form { display: grid; grid-template-columns: 1fr; justify-content: stretch; }
  .modal-card { width: calc(100vw - 20px); max-height: calc(100vh - 24px); border-radius: 18px; }
  .modal-body .grid-2, .modal-body .grid { grid-template-columns: 1fr; }
  .mobile-install { left: 10px; right: 10px; bottom: 10px; display: none; align-items: stretch; flex-direction: column; }
  .mobile-install.show { display: flex; }
  .mobile-install-actions .btn { flex: 1; }
}


.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 20% 20%, #dbeafe, transparent 32%), linear-gradient(135deg, #0f172a, #1e3a8a);
}
.login-screen[hidden], .app-shell[hidden] { display: none !important; }
.login-card {
  width: min(460px, 100%);
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .28);
  padding: 28px;
  display: grid;
  gap: 12px;
}
.login-brand { color: var(--text); margin-bottom: 6px; }
.login-brand span { color: var(--muted); }
.login-card h2 { margin: 8px 0 0; font-size: 28px; }
.login-card label { font-weight: 800; color: var(--text); }
.login-submit { margin-top: 6px; height: 44px; }
.demo-accounts {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.demo-accounts span { color: var(--muted); font-size: 13px; width: 100%; }
.user-switch strong { display: block; margin-top: 3px; }
.user-switch .tiny { display: block; margin-top: 3px; }
