:root {
  --background: hsl(222 20% 99%);
  --foreground: hsl(222 47% 11%);
  --card: hsl(0 0% 100%);
  --card-foreground: hsl(222 47% 11%);
  --primary: hsl(224 73% 58%);
  --secondary: hsl(222 24% 95%);
  --muted: hsl(222 24% 95%);
  --muted-foreground: hsl(222 12% 45%);
  --border: hsl(222 20% 92%);
  --success: hsl(142 71% 45%);
  --danger: hsl(0 84% 60%);
  --warning: hsl(38 92% 50%);
  --cyan: hsl(178 77% 45%);
  --purple: hsl(271 81% 62%);
  --radius: 14px;
  --shadow-sm: 0 2px 12px hsl(0 0% 0% / 0.04);
  --shadow-lg: 0 14px 40px hsl(222 47% 11% / 0.12);
  --font-sans: 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--background);
  color: var(--foreground);
}
button, input, select, textarea { font: inherit; }
a { color: inherit; }

.app-shell {
  min-height: 100vh;
  overflow-x: hidden;
}

.shell-inner {
  width: min(1200px, calc(100vw - 48px));
  margin: 0 auto;
}

.page-header {
  border-bottom: 1px solid var(--border);
  background: var(--background);
}

.page-title {
  margin: 0;
  padding-top: 36px;
  font-size: 34px;
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: -0.04em;
}

.page-subtitle {
  margin: 12px 0 0;
  font-size: 16px;
  font-weight: 300;
  color: var(--muted-foreground);
}

.header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.page-hint {
  margin: 8px 0 0;
  font-size: 18px;
  font-weight: 600;
  color: #3370eb;
}

.floor-select-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.floor-label {
  font-size: 14px;
  color: #8f959e;
  font-weight: 500;
}

.floor-select {
  padding: 8px 32px 8px 14px;
  border: 1px solid #e2e4e8;
  border-radius: 12px;
  background: #fff;
  color: #1f2329;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238f959e' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color .2s ease, box-shadow .2s ease;
}

.floor-select:hover {
  border-color: #3370eb;
}

.floor-select:focus {
  border-color: #3370eb;
  box-shadow: 0 0 0 3px rgba(51, 112, 235, 0.15);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
  padding-bottom: 30px;
}

.tag {
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--secondary);
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 600;
}

.page-main {
  padding: 32px 0 56px;
}

.dashboard-section {
  margin-bottom: 48px;
  animation: fadeIn 0.45s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 24px;
  font-size: 22px;
  font-weight: 800;
  color: #3370eb;
}

.section-title span {
  width: 4px;
  height: 26px;
  border-radius: 999px;
  background: #3370eb;
}

.grid {
  display: grid;
  gap: 24px;
}

.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }

.card {
  border: 1px solid #e2e4e8;
  border-radius: 18px;
  background: var(--card);
  color: var(--card-foreground);
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 22px 24px 10px;
}

.card-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #1f2329;
}

.card-header small {
  margin-left: 8px;
  color: #3370eb;
  font-size: 12px;
  font-weight: 500;
}

.card-body {
  padding: 0 24px 24px;
}

.chart { width: 100%; }
.chart-md { height: 320px; }
.chart-lg { height: 500px; }
.chart-xl { height: 500px; }

.mt-24 { margin-top: 24px; }
.mb-24 { margin-bottom: 24px; }
.danger-title { color: #ef4444; }

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

.kpi-card {
  padding: 20px;
  border-radius: 18px;
  border: 1px solid #e2e4e8;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s ease;
}

.kpi-card:hover { box-shadow: 0 8px 18px hsl(222 47% 11% / 0.08); }
.kpi-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.kpi-label { font-size: 14px; color: #8f959e; margin-bottom: 8px; }
.kpi-value { font-size: 32px; font-weight: 800; color: #3370eb; letter-spacing: -0.03em; }
.kpi-trend { margin-top: 12px; font-size: 12px; color: #8f959e; }
.kpi-trend span { color: #10b981; }
.kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: #f2f3f5;
  color: #3370eb;
  display: grid;
  place-items: center;
}
.kpi-icon svg { width: 20px; height: 20px; }

.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
  font-size: 14px;
}
.table thead { background: #f2f3f5; }
.table th, .table td { padding: 14px 16px; }
.table th {
  color: #8f959e;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}
.table td {
  color: #1f2329;
  border-top: 1px solid #e2e4e8;
}
.table td.align-right, .table th.align-right { text-align: right; }
.table td.align-center, .table th.align-center { text-align: center; }
.table tbody tr:hover { background: #f2f3f5; }
.table .sector-row { background: #f8f9fa; font-weight: 700; }
.table .shift-row td:first-child { padding-left: 34px; }
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  margin-right: 10px;
  vertical-align: middle;
}
.dot-sm { width: 6px; height: 6px; }
.sub-note { display: block; margin-top: 4px; color: #3370eb; font-size: 12px; }
.muted { color: #8f959e; }

.rank-list { display: flex; flex-direction: column; gap: 12px; max-height: 400px; overflow-y: auto; }
.rank-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  background: #f2f3f5;
  border-radius: 14px;
  cursor: pointer;
  transition: background .2s ease;
}
.rank-item:hover { background: #e8e9eb; }
.rank-item.danger { background: #fef2f2; }
.rank-item.danger:hover { background: #fee2e2; }
.rank-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.rank-badge {
  width: 24px; height: 24px; border-radius: 999px; display: grid; place-items: center;
  font-size: 12px; font-weight: 800; background: #e2e4e8; color: #8f959e;
}
.rank-badge.top { background: #3370eb; color: #fff; }
.rank-badge.bottom { background: #ef4444; color: #fff; }
.rank-name { font-size: 14px; font-weight: 600; color: #1f2329; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.rank-desc { font-size: 12px; color: #8f959e; margin-top: 4px; }
.rank-value { text-align: right; }
.rank-value strong { display: block; font-size: 14px; }
.rank-value.primary strong { color: #3370eb; }
.rank-value.danger strong { color: #ef4444; }
.rank-value span { font-size: 12px; color: #8f959e; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}
.metric-box {
  padding: 16px;
  background: #f2f3f5;
  border-radius: 16px;
}
.metric-box h4 { margin: 0 0 14px; font-size: 14px; color: #1f2329; }
.metric-action {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .2s ease;
}
.metric-action:hover { background: #fff; }
.metric-action span:first-child { font-size: 12px; color: #8f959e; }
.metric-action strong { font-size: 14px; }
.metric-action .success { color: #10b981; }
.metric-action .danger { color: #ef4444; }

.metric-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background .2s ease;
}
.metric-pill.success { background: #dcfce7; color: #166534; }
.metric-pill.success:hover { background: #bbf7d0; }
.metric-pill.danger { background: #fee2e2; color: #991b1b; }
.metric-pill.danger:hover { background: #fecaca; }
.shift-dot { margin-right: 8px; }

.productivity-item {
  padding: 10px;
  border-radius: 14px;
  cursor: pointer;
  transition: background .2s ease;
}
.productivity-item:hover { background: #f2f3f5; }
.productivity-row { display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.productivity-row strong { font-size: 14px; color: #1f2329; }
.productivity-row span { font-size: 13px; color: #8f959e; }
.productivity-bar { margin-top: 10px; height: 8px; background: #f2f3f5; border-radius: 999px; overflow: hidden; }
.productivity-bar-fill { height: 100%; border-radius: 999px; transition: width .5s ease; }
.insight-box {
  margin-top: 24px;
  padding: 16px;
  background: #f2f3f5;
  border-radius: 16px;
}
.insight-box h4 { margin: 0 0 10px; font-size: 14px; color: #1f2329; }
.insight-box ul { margin: 0; padding-left: 18px; color: #8f959e; font-size: 14px; line-height: 1.7; }

.summary-card {
  display: flex;
  gap: 14px;
  padding: 24px;
  border-radius: 18px;
  border-left: 4px solid #3370eb;
  background: #f2f3f5;
}
.summary-icon {
  width: 24px;
  height: 24px;
  color: #3370eb;
  flex: 0 0 auto;
}
.summary-title { font-size: 16px; font-weight: 700; color: #1f2329; margin-bottom: 10px; }
.summary-points { color: #8f959e; font-size: 14px; line-height: 1.75; }
.summary-points p { margin: 6px 0; }

.sidebar-mask {
  position: fixed;
  inset: 0;
  background: hsl(222 47% 11% / 0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
  z-index: 40;
}
.sidebar-mask.visible { opacity: 1; pointer-events: auto; }

.sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: min(384px, 92vw);
  height: 100vh;
  background: #fff;
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform .3s cubic-bezier(.32,.72,0,1);
  z-index: 50;
  display: flex;
  flex-direction: column;
}
.sidebar.open { transform: translateX(0); }

body.sidebar-open { overflow: hidden; }
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid #e2e4e8;
}
.sidebar-head h3 { margin: 0; font-size: 20px; color: #1f2329; }
.sidebar-close {
  width: 40px; height: 40px; border: 0; border-radius: 12px; background: transparent; cursor: pointer; color: #8f959e;
}
.sidebar-close:hover { background: #f2f3f5; }
.sidebar-close svg { width: 20px; height: 20px; }
.sidebar-body { padding: 16px; overflow-y: auto; }
.sidebar-count { margin: 0 0 16px; font-size: 14px; color: #8f959e; }
.sidebar-list { display: flex; flex-direction: column; gap: 10px; }
.sidebar-item {
  padding: 14px;
  background: #f2f3f5;
  border-radius: 14px;
  transition: background .2s ease;
}
.sidebar-item:hover { background: #e8e9eb; }
.sidebar-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sidebar-name { font-weight: 600; color: #1f2329; }
.sidebar-track { font-size: 12px; color: #8f959e; }
.sidebar-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  color: #8f959e;
  font-size: 13px;
}
.sidebar-extra { margin-top: 4px; font-size: 12px; }
.sidebar-extra span:first-child { color: #8f959e; }
.sidebar-extra strong { font-weight: 700; }

.success { color: #10b981; }
.danger { color: #ef4444; }

@media (max-width: 1100px) {
  .grid-3, .grid-2, .metric-grid, .kpi-grid { grid-template-columns: 1fr 1fr; }
  .span-2 { grid-column: span 2; }
}

@media (max-width: 768px) {
  .shell-inner { width: min(100vw - 28px, 1200px); }
  .page-title { font-size: 28px; }
  .grid-3, .grid-2, .metric-grid, .kpi-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .page-main { padding-top: 24px; }
  .chart-lg, .chart-xl { height: 420px; }
}
