:root {
  color-scheme: light;
  --bg: #f7f9fc;
  --surface: #ffffff;
  --surface-soft: #f9fbff;
  --text: #333333;
  --muted: #666666;
  --subtle: #666666;
  --line: #e5e7eb;
  --line-soft: #f1f3f5;
  --primary: #1e40af;
  --primary-strong: #172554;
  --primary-soft: #eaf1ff;
  --cyan: #0891b2;
  --cyan-soft: #e6f7fb;
  --accent: #b86b00;
  --success: #15803d;
  --warning: #b86b00;
  --danger: #dc2626;
  --sidebar: #ffffff;
  --sidebar-line: #e5e7eb;
  --shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 6px 16px rgba(15, 23, 42, 0.05);
  --number-font: "SF Mono", "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(234, 241, 255, 0.72) 0, rgba(247, 249, 252, 0) 320px),
    radial-gradient(circle at 92% 8%, rgba(8, 145, 178, 0.08), transparent 300px),
    var(--bg);
  color: var(--text);
  font-family: Helvetica, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  touch-action: manipulation;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 180px;
  padding: 22px 14px;
  background: var(--sidebar);
  border-right: 1px solid var(--sidebar-line);
  color: var(--text);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
  padding: 0 2px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.08);
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand strong {
  display: block;
}

.brand strong {
  color: var(--text);
  font-size: 15px;
}

.nav-item {
  position: relative;
  width: 100%;
  height: 42px;
  margin-bottom: 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  padding: 0 14px;
  font-size: 14px;
  cursor: pointer;
  transition: background 180ms ease, border-color 180ms ease, color 180ms ease;
}

.nav-item.active {
  border-color: transparent;
  background: #f1f5f9;
  color: var(--text);
  font-weight: 400;
}

.nav-item:disabled {
  cursor: not-allowed;
  color: var(--muted);
}

.sidebar-footer {
  position: absolute;
  right: 14px;
  bottom: 18px;
  left: 14px;
  border-top: 1px solid var(--sidebar-line);
  padding: 14px 8px 0;
  color: var(--muted);
  font-size: 12px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.sidebar-user[hidden] {
  display: none;
}

.sidebar-user-name {
  color: var(--text);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-logout {
  flex: none;
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
  transition: color 180ms ease;
}

.sidebar-logout:hover,
.sidebar-logout:focus-visible {
  color: var(--danger);
}

.sidebar-footer-label {
  display: block;
}

.page {
  margin-left: 180px;
  padding: 24px 20px 36px;
}

.page-header {
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.page-title-row {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
}

.page-date-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.time-dimension-select {
  flex: 0 0 72px;
  width: 88px;
  height: 32px;
  font-size: 14px;
  padding: 0 8px;
}

.date-quick-button {
  height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  padding: 0 10px;
  transition: background 180ms ease, color 180ms ease;
}

.date-quick-button:hover,
.date-quick-button.active {
  background: #eaf2ff;
  color: #197afb;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  color: var(--text);
  font-size: 28px;
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: 0;
}

.data-source {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border: 1px solid rgba(8, 145, 178, 0.28);
  border-radius: 999px;
  padding: 0 12px;
  background: var(--cyan-soft);
  color: #155e75;
  font-size: 12px;
  font-weight: 400;
  white-space: nowrap;
}

.data-source::before {
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: #06b6d4;
  box-shadow: 0 0 0 4px rgba(6, 182, 212, 0.12);
  content: "";
}

.panel,
.metric {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

.filters {
  display: grid;
  grid-template-columns: minmax(260px, 1.4fr) repeat(2, minmax(136px, 1fr)) auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  margin-bottom: 14px;
}

.filters.user-filters {
  grid-template-columns: minmax(260px, 1.4fr) repeat(3, minmax(136px, 1fr)) auto;
}

.filters.recharge-filters {
  grid-template-columns: minmax(260px, 1.4fr) auto;
}

.recharge-filters .task-filter-field {
  display: none;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.filter-field {
  display: grid;
  gap: 6px;
}

.filter-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

input,
select {
  width: 100%;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 0 10px;
  outline: none;
  transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

input:focus,
select:focus {
  border-color: var(--cyan);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.12);
}

.search-input-wrap {
  position: relative;
  display: block;
}

.search-input-icon {
  position: absolute;
  top: 50%;
  left: 10px;
  z-index: 1;
  pointer-events: none;
  transform: translateY(-50%);
}

.search-input-wrap input {
  padding-left: 34px;
}

.date-range-field {
  position: relative;
}

.header-date-filter {
  display: flex;
  align-items: center;
  width: 322px;
  flex: 0 0 322px;
  gap: 10px;
}

.header-date-filter .filter-label {
  flex: 0 0 auto;
  font-size: 14px;
  white-space: nowrap;
}

.header-date-filter .date-range-picker {
  flex: 1;
  min-width: 0;
}

.date-range-picker {
  position: relative;
  display: block;
}

.date-range-toggle {
  width: 100%;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  padding: 0 10px;
  text-align: left;
  transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.date-range-toggle:focus,
.date-range-toggle[aria-expanded="true"] {
  border-color: var(--cyan);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.12);
}

.date-range-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 8;
  width: 758px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
  padding: 0;
  overflow: hidden;
}

.date-range-dropdown:not([hidden]) {
  display: grid;
  grid-template-columns: 110px 1fr;
}

.date-range-shortcuts {
  display: grid;
  align-content: start;
  border-right: 1px solid var(--line);
  gap: 0;
  padding: 10px 12px;
  background: #fff;
}

.date-shortcut {
  height: 32px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  padding: 0;
  text-align: left;
  transition: background 180ms ease, color 180ms ease;
}

.date-shortcut:hover,
.date-shortcut.active {
  background: transparent;
  color: #1677ff;
}

.date-range-main {
  min-width: 0;
  padding: 0;
}

.header-date-filter .date-range-dropdown {
  right: 0;
  left: auto;
}

.calendar-block strong {
  color: var(--text);
  font-size: 16px;
  font-weight: 400;
}

.date-range-nav {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #8a8f98;
  cursor: pointer;
  font-size: 14px;
  padding: 0;
  transition: color 180ms ease;
}

.date-range-nav:hover {
  color: #333333;
}

.date-range-nav.is-disabled {
  color: #c7ced8;
  cursor: default;
  pointer-events: none;
}

.date-range-calendars {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.calendar-block {
  display: grid;
  gap: 10px;
  padding: 18px 24px 24px;
}

.calendar-block + .calendar-block {
  border-left: 1px solid var(--line);
}

.calendar-title-row {
  display: grid;
  grid-template-columns: 64px 1fr 64px;
  align-items: center;
  min-height: 24px;
  text-align: center;
}

.calendar-title-row > span {
  display: flex;
  justify-content: flex-start;
}

.calendar-title-row > span:last-child {
  justify-content: flex-end;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px 8px;
}

.calendar-weekday,
.calendar-day {
  display: grid;
  place-items: center;
  min-width: 0;
  height: 34px;
  border-radius: 4px;
  font-size: 14px;
}

.calendar-weekday {
  color: var(--muted);
  font-weight: 400;
}

.calendar-day {
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-family: var(--number-font);
  font-variant-numeric: tabular-nums;
}

.calendar-day:hover {
  color: #1677ff;
  background: transparent;
}

.calendar-day.is-muted {
  color: #c7ced8;
}

.calendar-day.is-in-range {
  background: #edf6ff;
  color: #1677ff;
}

.calendar-day.is-selected {
  background: transparent;
  color: #1677ff;
}

.filter-actions {
  display: flex;
  gap: 8px;
}

.button {
  height: 32px;
  min-width: 68px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 400;
  transition: background 180ms ease, border-color 180ms ease, box-shadow 180ms ease, color 180ms ease;
}

.button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  box-shadow: 0 8px 18px rgba(30, 64, 175, 0.22);
}

.button.primary:hover {
  background: #1d4ed8;
}

#queryButton {
  border-color: #197afb;
  background: #197afb;
}

#queryButton:hover {
  border-color: #197afb;
  background: #197afb;
}

.button.ghost {
  background: #fff;
  color: var(--text);
}

.button.ghost:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
}

.button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metric {
  position: relative;
  overflow: hidden;
  min-height: 104px;
  padding: 14px;
}

.metric::after {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(148, 163, 184, 0.16) 1px, transparent 1px),
    linear-gradient(180deg, rgba(148, 163, 184, 0.16) 1px, transparent 1px);
  background-size: 8px 8px;
  content: "";
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 8px;
  color: var(--text);
  font-family: var(--number-font);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.15;
}

.metric small {
  display: block;
  margin-top: 8px;
  color: var(--subtle);
  font-size: 12px;
}

.table-panel {
  padding: 0;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
  background: linear-gradient(180deg, #fff, #f9fbff);
}

.section-title h2 {
  color: var(--text);
  font-size: 17px;
  font-weight: 400;
}

.section-title span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.table-wrap {
  width: 100%;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1220px;
}

th,
td {
  min-width: 80px;
  height: 44px;
  border-bottom: 1px solid var(--line-soft);
  padding: 0 12px;
  text-align: left;
  white-space: nowrap;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  background: #f1f5fb;
}

.sort-button {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  width: 100%;
  height: 32px;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-align: right;
}

.sort-button::after {
  width: 10px;
  color: #a0a7b3;
  content: "↕";
  font-size: 11px;
  line-height: 1;
}

.sort-button.active {
  color: #333333;
}

.sort-button.active[data-sort-direction="desc"]::after {
  color: #197afb;
  content: "↓";
}

.sort-button.active[data-sort-direction="asc"]::after {
  color: #197afb;
  content: "↑";
}

.col-text {
  text-align: left;
}

.col-number {
  text-align: right;
  font-family: var(--number-font);
  font-variant-numeric: tabular-nums;
}

.col-action {
  text-align: left;
}

.enterprise-tag-cell {
  width: 120px;
  min-width: 120px;
  max-width: 120px;
}

.enterprise-tag {
  display: inline-flex;
  align-items: center;
  min-width: 64px;
  height: 24px;
  border-radius: 6px;
  background: var(--tag-bg, #f5f5f5);
  color: #333333;
  cursor: text;
  padding: 0 8px;
}

.enterprise-tag-input {
  width: 100%;
  height: 32px;
  border: 1px solid #1677ff;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 8px;
}

.col-enterprise-name {
  min-width: 220px;
  max-width: 280px;
}

.enterprise-identity {
  display: flex;
  align-items: center;
}

.enterprise-name-line {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.enterprise-name-line .enterprise-name-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.enterprise-follow-indicator {
  display: inline-grid;
  flex: 0 0 16px;
  place-items: center;
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
  color: #dc2626;
}

.enterprise-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.enterprise-name-text,
.enterprise-id-subtext,
.name-text,
.id-subtext {
  display: block;
}

.enterprise-id-subtext,
.id-subtext {
  margin-top: 4px;
  color: #666666;
  font-size: 12px;
}

.col-user-name {
  width: 160px;
  min-width: 160px;
  max-width: 160px;
}

.col-user-enterprise-name {
  width: 200px;
  min-width: 200px;
  max-width: 200px;
}

.sticky-enterprise-name {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #fff;
  box-shadow: 10px 0 16px -14px rgba(15, 23, 42, 0.35);
}

.sticky-user-name {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #fff;
  box-shadow: 10px 0 16px -14px rgba(15, 23, 42, 0.35);
}

.sticky-enterprise-action {
  position: sticky;
  right: 0;
  z-index: 2;
  width: 156px;
  min-width: 156px;
  background: #fff;
  box-shadow: -10px 0 16px -14px rgba(15, 23, 42, 0.35);
}

th.sticky-enterprise-name,
th.sticky-user-name,
th.sticky-enterprise-action {
  z-index: 3;
  background: #f1f5fb;
}

td.sticky-enterprise-name,
td.sticky-user-name {
  white-space: normal;
  line-height: 1.35;
}

tbody tr {
  transition: background 160ms ease;
}

tbody tr:hover {
  background: #f6fbff;
}

tbody tr:hover td.sticky-enterprise-name {
  background: #f6fbff;
}

tbody tr:hover td.sticky-user-name {
  background: #f6fbff;
}

tbody tr:hover td.sticky-enterprise-action {
  background: #f6fbff;
}

.link-button {
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: #1677ff;
  color: #fff;
  cursor: pointer;
  padding: 0 10px;
  font-weight: 400;
  box-shadow: none;
  transition: background 180ms ease, border-color 180ms ease, color 180ms ease;
}

.link-button:hover {
  background: #0958d9;
  color: #fff;
}

.text-button {
  height: 32px;
  border: 0;
  background: transparent;
  color: #197afb;
  cursor: pointer;
  padding: 0;
  font-size: 14px;
}

.text-button:hover {
  color: #0958d9;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-width: 24px;
  height: 24px;
  border-radius: 999px;
  padding: 0 8px;
  background: #edf2f8;
  color: var(--text);
  font-size: 12px;
  font-weight: 400;
}

.badge.success {
  background: #e8f7ee;
  color: var(--success);
}

.badge.warning {
  background: #fff4df;
  color: var(--warning);
}

.badge.danger {
  background: #feecec;
  color: var(--danger);
}

.empty-state {
  padding: 36px 0 24px;
  text-align: center;
  color: var(--muted);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9;
  background: rgba(15, 23, 42, 0.48);
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(940px, 92vw);
  height: 100vh;
  transform: translateX(100%);
  transition: transform 200ms ease;
  background: #fff;
  border-left: 1px solid var(--line);
  box-shadow: -18px 0 36px rgba(15, 23, 42, 0.2);
  padding: 0;
  z-index: 10;
}

.drawer.open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding: 18px 20px;
  background: linear-gradient(180deg, #fff, #f8fbff);
}

.drawer-header h2 {
  color: var(--text);
  font-size: 19px;
  font-weight: 400;
}

.drawer-header p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.icon-button {
  width: 36px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  color: var(--text);
  font-size: 24px;
  line-height: 1;
  transition: background 180ms ease, border-color 180ms ease;
}

.icon-button:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
}

.drawer-table {
  height: calc(100vh - 74px);
  overflow: auto;
}

.drawer-table table {
  width: max-content;
  min-width: 100%;
}

.drawer-table th,
.drawer-table td {
  width: 1%;
  min-width: 0;
  max-width: 160px;
  white-space: nowrap;
}

.drawer-table th {
  overflow: hidden;
  text-overflow: ellipsis;
}

.drawer-table td .name-text,
.drawer-table td .id-subtext {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-time {
  position: relative;
  display: block;
  white-space: nowrap;
}

.detail-time-tooltip {
  position: absolute;
  z-index: 30;
  width: max-content;
  max-width: 260px;
  padding: 6px 8px;
  border-radius: 4px;
  background: #333333;
  color: #ffffff;
  font-size: 12px;
  line-height: 1.4;
  pointer-events: none;
  white-space: nowrap;
}

.video-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 19;
  background: rgba(15, 23, 42, 0.56);
}

.video-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 20;
  width: min(760px, calc(100vw - 40px));
  transform: translate(-50%, -48%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 56px rgba(15, 23, 42, 0.24);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.video-modal.open {
  transform: translate(-50%, -50%);
  opacity: 1;
  pointer-events: auto;
}

.video-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
}

.video-modal-header h2 {
  color: var(--text);
  font-size: 16px;
  font-weight: 400;
}

.video-modal-body {
  padding: 16px;
}

.video-modal video {
  display: block;
  width: 100%;
  max-height: min(70vh, 620px);
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  background: #111827;
}

.video-playlist-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 32px;
  margin-top: 12px;
  color: #666666;
  font-size: 13px;
}

.video-playlist-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.video-playlist-actions .text-button:disabled {
  color: #b5b5b5;
  cursor: not-allowed;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 1180px) {
  .filters {
    grid-template-columns: repeat(3, 1fr);
  }

  .metric-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 760px) {
  .sidebar {
    position: static;
    width: auto;
    height: auto;
  }

  .sidebar-footer {
    display: none;
  }

  .page {
    margin-left: 0;
    padding: 18px 20px;
  }

  .page-header {
    display: grid;
    gap: 12px;
  }

  .data-source {
    margin-top: 0;
  }

  .page-title-row {
    flex-wrap: wrap;
  }

  .header-date-filter {
    width: 100%;
    flex-basis: auto;
  }

  .filters,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .filter-actions {
    justify-content: flex-end;
  }
}
