:root {
  color-scheme: light;
  --brand: #f47721;
  --brand-strong: #d95f0b;
  --brand-soft: #fff3e9;
  --brand-faint: #fffaf6;
  --ink: #18191b;
  --ink-2: #3a3d42;
  --muted: #727780;
  --muted-2: #999ea6;
  --line: #e7e8ea;
  --line-strong: #d9dbde;
  --surface: #ffffff;
  --canvas: #f6f7f8;
  --sidebar: #191a1d;
  --sidebar-muted: #989ba2;
  --success: #16815d;
  --success-bg: #eaf7f1;
  --warning: #9d6200;
  --warning-bg: #fff5dc;
  --danger: #bc3434;
  --danger-bg: #fff0f0;
  --info: #315f9f;
  --info-bg: #edf3ff;
  --shadow-card: 0 1px 2px rgba(17, 19, 23, 0.03);
  --shadow-pop: 0 20px 60px rgba(20, 22, 27, 0.1);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --sidebar-width: 248px;
  font-family:
    Inter, "SF Pro Text", "Segoe UI", "PingFang SC",
    "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--canvas);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* 登录 */

.login-view {
  display: grid;
  min-height: 100vh;
  padding: 28px;
  background:
    linear-gradient(135deg, rgba(244, 119, 33, 0.08), transparent 34%),
    radial-gradient(circle at 88% 82%, rgba(244, 119, 33, 0.08), transparent 26%),
    var(--canvas);
  place-items: center;
}

.login-card {
  width: min(100%, 430px);
  padding: 36px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
}

.login-brand,
.sidebar-brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.login-brand > span:last-child,
.sidebar-brand > span:last-child {
  min-width: 0;
}

.login-brand strong,
.sidebar-brand strong {
  display: block;
  font-size: 16px;
  line-height: 1.25;
}

.login-brand > span:last-child small,
.sidebar-brand > span:last-child small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.05em;
}

.brand-mark {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: baseline;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding-top: 14px;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.05em;
  background: linear-gradient(145deg, #ff9f3e, var(--brand) 58%, #e7650e);
  border: 1px solid rgba(211, 82, 0, 0.22);
  border-radius: 13px;
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.45),
    0 8px 18px rgba(226, 93, 5, 0.18);
}

.brand-mark small {
  margin-left: 1px;
  font-size: 6px;
  letter-spacing: -0.04em;
}

.brand-mark-small {
  width: 40px;
  height: 40px;
  padding-top: 12px;
  font-size: 11px;
  border-radius: 11px;
  box-shadow: none;
}

.brand-mark-small small {
  font-size: 5px;
}

.login-copy {
  margin: 38px 0 26px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 7px;
  color: var(--brand-strong);
  font-size: 10px;
  font-weight: 760;
  letter-spacing: 0.13em;
}

.login-copy h1,
.topbar h1,
.section-heading h2,
.panel-heading h3 {
  margin: 0;
  letter-spacing: -0.025em;
}

.login-copy h1 {
  font-size: 30px;
  line-height: 1.2;
}

.login-copy > p:last-child {
  margin: 11px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.login-form {
  display: grid;
  gap: 17px;
}

.field {
  display: grid;
  gap: 8px;
}

.field > span {
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 650;
}

.field input,
.search-field input {
  min-width: 0;
  color: var(--ink);
  outline: none;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease,
    background-color 150ms ease;
}

.field input {
  width: 100%;
  height: 46px;
  padding: 0 13px;
  border-radius: 9px;
}

.field input::placeholder,
.search-field input::placeholder {
  color: var(--muted-2);
}

.field input:focus,
.search-field:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(244, 119, 33, 0.12);
}

.form-message {
  min-height: 20px;
  margin: -4px 0;
  color: var(--danger);
  font-size: 12px;
  line-height: 1.55;
}

.login-security {
  margin: 20px 0 0;
  color: var(--muted-2);
  font-size: 11px;
  text-align: center;
}

/* 通用控件 */

.button {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  font-size: 12px;
  font-weight: 670;
  line-height: 1;
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  transition:
    color 140ms ease,
    background-color 140ms ease,
    border-color 140ms ease,
    box-shadow 140ms ease;
}

.button:focus-visible,
.nav-link:focus-visible,
.global-alert button:focus-visible {
  outline: 3px solid rgba(244, 119, 33, 0.28);
  outline-offset: 2px;
}

.button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.button-primary {
  height: 46px;
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
  box-shadow: 0 5px 14px rgba(225, 91, 4, 0.16);
}

.button-primary:hover:not(:disabled) {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
}

.button-secondary {
  color: var(--ink-2);
  background: var(--surface);
  border-color: var(--line-strong);
}

.button-secondary:hover:not(:disabled) {
  color: var(--brand-strong);
  border-color: #efb58c;
  background: var(--brand-faint);
}

.button-quiet {
  color: var(--muted);
  background: transparent;
  border-color: var(--line);
}

.button-quiet:hover:not(:disabled) {
  color: var(--ink);
  background: #f1f2f3;
}

.button-block {
  width: 100%;
}

.button-spinner {
  display: none;
  width: 13px;
  height: 13px;
  border: 2px solid rgba(255, 255, 255, 0.48);
  border-top-color: #fff;
  border-radius: 50%;
}

.button.is-loading .button-spinner {
  display: inline-block;
  animation: spin 700ms linear infinite;
}

/* 框架 */

.admin-app {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-width);
  padding: 22px 16px 18px;
  color: #fff;
  background: var(--sidebar);
  border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-brand {
  padding: 0 7px 26px;
}

.sidebar-brand > span:last-child small {
  color: var(--sidebar-muted);
}

.nav-group-label {
  padding: 0 10px 8px;
  color: #666a72;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.sidebar-nav {
  display: grid;
  gap: 4px;
}

.nav-link {
  display: flex;
  gap: 11px;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  color: #b8bbc1;
  font-size: 13px;
  font-weight: 590;
  text-decoration: none;
  border-radius: 9px;
  transition:
    color 140ms ease,
    background-color 140ms ease;
}

.nav-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.nav-link.is-active {
  color: #fff;
  background: rgba(244, 119, 33, 0.16);
  box-shadow: inset 3px 0 var(--brand);
}

.nav-link svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
}

.sidebar-footer {
  display: grid;
  gap: 10px;
  margin-top: auto;
}

.session-state {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 0 8px;
  color: var(--sidebar-muted);
  font-size: 10px;
}

.status-dot {
  width: 7px;
  height: 7px;
  background: #32b87e;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(50, 184, 126, 0.12);
}

.sidebar-footer .button-quiet {
  color: #aeb1b7;
  border-color: rgba(255, 255, 255, 0.1);
}

.sidebar-footer .button-quiet:hover:not(:disabled) {
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
}

.main-content {
  width: calc(100% - var(--sidebar-width));
  min-height: 100vh;
  margin-left: var(--sidebar-width);
  padding: 27px clamp(24px, 3.6vw, 54px) 34px;
}

.topbar {
  display: flex;
  gap: 28px;
  align-items: center;
  justify-content: space-between;
  max-width: 1480px;
  min-height: 64px;
  margin: 0 auto 24px;
}

.topbar .eyebrow {
  margin-bottom: 4px;
}

.topbar h1 {
  font-size: clamp(24px, 2.5vw, 30px);
  line-height: 1.18;
}

.page-subtitle {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.topbar-actions {
  display: flex;
  gap: 14px;
  align-items: center;
}

.refresh-meta {
  display: grid;
  gap: 2px;
  color: var(--muted-2);
  font-size: 10px;
  text-align: right;
}

.refresh-meta time {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.refresh-icon {
  font-size: 16px;
}

.is-loading .refresh-icon {
  animation: spin 700ms linear infinite;
}

.global-alert {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  max-width: 1480px;
  padding: 12px 14px;
  margin: 0 auto 18px;
  color: var(--danger);
  font-size: 12px;
  line-height: 1.55;
  background: var(--danger-bg);
  border: 1px solid #efcaca;
  border-radius: 9px;
}

.global-alert.is-warning {
  color: var(--warning);
  background: var(--warning-bg);
  border-color: #ecd49c;
}

.global-alert button {
  padding: 0;
  color: currentColor;
  font-size: 18px;
  cursor: pointer;
  background: transparent;
  border: 0;
}

/* 页面内容 */

.dashboard-section {
  max-width: 1480px;
  margin: 0 auto 38px;
}

.dashboard-section:not(.is-current) {
  display: none;
}

.section-heading {
  display: flex;
  gap: 20px;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 15px;
}

.section-kicker {
  margin-bottom: 4px;
}

.section-heading h2 {
  font-size: 18px;
  line-height: 1.3;
}

.section-note {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 11px;
}

.metric-grid {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.metric-grid-four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric-grid-three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.metric-card-primary {
  background:
    linear-gradient(135deg, rgba(244, 119, 33, 0.08), transparent 64%),
    var(--surface);
  border-color: #efc4a4;
}

.metric-card.is-negative-margin {
  background: var(--danger-bg);
  border-color: rgba(188, 52, 52, 0.42);
}

.metric-card.is-negative-margin .metric-label,
.metric-card.is-negative-margin .metric-value,
.metric-card.is-negative-margin .metric-note {
  color: var(--danger);
}

.metric-label {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
  font-weight: 620;
}

.metric-tag {
  padding: 3px 6px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 650;
  background: #f2f3f4;
  border-radius: 5px;
}

.metric-card-primary .metric-tag {
  color: var(--brand-strong);
  background: var(--brand-soft);
}

.metric-value {
  display: block;
  overflow: hidden;
  margin: 14px 0 7px;
  color: var(--ink);
  font-size: clamp(24px, 2.2vw, 31px);
  font-weight: 730;
  line-height: 1.06;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
}

.metric-note {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.panel-heading {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 17px 18px 12px;
}

.panel-heading h3 {
  font-size: 14px;
  line-height: 1.4;
}

.panel-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.overview-secondary-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.9fr) minmax(260px, 0.8fr);
  gap: 12px;
  margin-bottom: 12px;
}

.chart-legend {
  display: flex;
  gap: 12px;
  align-items: center;
  color: var(--muted);
  font-size: 9px;
}

.chart-legend span {
  display: inline-flex;
  gap: 5px;
  align-items: center;
}

.legend-swatch {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.legend-primary {
  background: var(--brand);
}

.legend-secondary {
  background: #c9cdd2;
}

.activity-chart {
  display: flex;
  gap: clamp(6px, 1.5vw, 16px);
  align-items: stretch;
  min-height: 220px;
  padding: 10px 18px 15px;
  overflow-x: auto;
}

.chart-column {
  display: grid;
  flex: 1 0 42px;
  grid-template-rows: 1fr auto;
  gap: 8px;
  min-width: 42px;
  text-align: center;
}

.chart-bars {
  display: flex;
  gap: 3px;
  align-items: flex-end;
  justify-content: center;
  height: 174px;
  padding-top: 24px;
  border-bottom: 1px solid var(--line);
}

.chart-bar {
  position: relative;
  width: min(13px, 38%);
  min-height: 2px;
  border-radius: 4px 4px 1px 1px;
}

.chart-bar-primary {
  background: linear-gradient(to top, var(--brand-strong), #ff9a52);
}

.chart-bar-secondary {
  background: #c9cdd2;
}

.chart-bar::after {
  position: absolute;
  bottom: calc(100% + 5px);
  left: 50%;
  z-index: 2;
  display: none;
  padding: 4px 6px;
  color: #fff;
  font-size: 9px;
  white-space: nowrap;
  content: attr(data-value);
  background: var(--ink);
  border-radius: 5px;
  transform: translateX(-50%);
}

.chart-bar:hover::after,
.chart-bar:focus-visible::after {
  display: block;
}

.chart-label {
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.snapshot-list {
  display: grid;
  padding: 0 18px 14px;
}

.snapshot-list > div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 5px 14px;
  align-items: center;
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.snapshot-list span {
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 630;
}

.snapshot-list strong {
  color: var(--ink);
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}

.snapshot-list small {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 10px;
}

.unavailable-panel {
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
}

.unavailable-copy strong {
  font-size: 12px;
}

.unavailable-copy p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.55;
}

/* 搜索与筛选 */

.filter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
  justify-content: flex-end;
}

.filter-field {
  display: grid;
  gap: 5px;
  min-width: 132px;
}

.filter-field-search {
  min-width: min(310px, 100%);
}

.filter-label {
  color: var(--muted);
  font-size: 9px;
  font-weight: 680;
}

.search-field {
  display: flex;
  gap: 8px;
  align-items: center;
  width: min(100%, 310px);
  height: 38px;
  padding-left: 11px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
}

.search-field svg {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  fill: currentColor;
}

.search-field input {
  width: 100%;
  height: 100%;
  padding: 0 10px 0 0;
  border: 0;
  border-radius: 0;
}

.search-field input:focus {
  box-shadow: none;
}

.filter-field select {
  height: 38px;
  padding: 0 32px 0 10px;
  color: var(--ink-2);
  cursor: pointer;
  outline: none;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
}

.filter-field select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(244, 119, 33, 0.1);
}

/* 表格 */

.table-panel {
  margin-bottom: 12px;
}

.table-summary {
  border-bottom: 1px solid var(--line);
}

.panel-heading-with-filters {
  align-items: flex-end;
  padding-bottom: 13px;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
}

#model-usage table {
  min-width: 1160px;
}

th,
td {
  padding: 13px 18px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

th {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.025em;
  background: #fafafa;
}

td {
  color: var(--ink-2);
  font-size: 11px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: var(--brand-faint);
}

tbody tr.is-negative-margin {
  background: var(--danger-bg);
}

tbody tr.is-negative-margin:hover {
  background: #ffe7e7;
}

.negative-value {
  color: var(--danger);
  font-weight: 750;
}

.align-right {
  text-align: right;
}

.user-cell,
.order-cell,
.model-cell {
  display: grid;
  gap: 3px;
  min-width: 150px;
}

.user-cell strong,
.order-cell strong,
.model-cell strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 11px;
  font-weight: 680;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-cell small,
.order-cell small,
.model-cell small {
  overflow: hidden;
  max-width: 270px;
  color: var(--muted);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 9px;
  color: var(--brand-strong);
  font-size: 10px;
  font-weight: 670;
  cursor: pointer;
  background: var(--brand-faint);
  border: 1px solid #f0c8aa;
  border-radius: 7px;
}

.table-action:hover:not(:disabled) {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
}

.table-action:focus-visible {
  outline: 3px solid rgba(244, 119, 33, 0.22);
  outline-offset: 2px;
}

.table-action:disabled {
  color: var(--muted-2);
  cursor: default;
  background: #f3f4f5;
  border-color: var(--line);
}

.order-cell .table-action {
  justify-content: flex-start;
  width: fit-content;
  min-height: 22px;
  padding: 0;
  overflow: hidden;
  color: var(--brand-strong);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: transparent;
  border: 0;
}

.order-cell .table-action:hover:not(:disabled) {
  color: var(--brand-strong);
  text-decoration: underline;
  background: transparent;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 7px;
  font-size: 9px;
  font-weight: 680;
  white-space: nowrap;
  border-radius: 999px;
}

.status-success {
  color: var(--success);
  background: var(--success-bg);
}

.status-warning {
  color: var(--warning);
  background: var(--warning-bg);
}

.status-danger {
  color: var(--danger);
  background: var(--danger-bg);
}

.status-neutral {
  color: var(--muted);
  background: #f0f1f2;
}

.status-info {
  color: var(--info);
  background: var(--info-bg);
}

.pagination-bar {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  padding: 10px 18px;
  border-top: 1px solid var(--line);
}

.pagination-info,
.pagination-page {
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.pagination-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.pagination-controls .button {
  min-height: 32px;
  padding-inline: 11px;
  font-size: 10px;
}

.pagination-page {
  min-width: 76px;
  text-align: center;
}

.empty-state {
  display: grid;
  min-height: 180px;
  padding: 32px 20px;
  text-align: center;
  place-items: center;
  align-content: center;
}

.compact-empty {
  min-height: 150px;
  border-top: 1px solid var(--line);
}

.empty-symbol {
  display: inline-grid;
  width: 38px;
  height: 38px;
  margin-bottom: 10px;
  color: var(--brand-strong);
  font-size: 14px;
  place-items: center;
  background: var(--brand-soft);
  border: 1px solid #f2cfb6;
  border-radius: 10px;
}

.empty-state strong {
  font-size: 12px;
}

.empty-state p {
  max-width: 520px;
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.55;
}

.empty-state.is-error .empty-symbol {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: #efcaca;
}

.ledger-panel {
  margin-top: 12px;
}

/* 用户详情抽屉 */

.has-open-drawer {
  overflow: hidden;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(13, 15, 18, 0.36);
  backdrop-filter: blur(2px);
}

.detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 90;
  width: min(620px, calc(100vw - 32px));
  overflow-y: auto;
  color: var(--ink);
  background: var(--canvas);
  border-left: 1px solid var(--line);
  box-shadow: -20px 0 60px rgba(17, 19, 23, 0.16);
}

.drawer-header {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  gap: 20px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 24px 26px 18px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.drawer-header .section-kicker {
  margin-bottom: 5px;
}

.drawer-header h2 {
  max-width: 470px;
  margin: 0;
  overflow: hidden;
  font-size: 21px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer-user-id {
  max-width: 470px;
  margin: 6px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer-close {
  display: inline-grid;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  padding: 0;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  background: #f2f3f4;
  border: 1px solid var(--line);
  border-radius: 9px;
  place-items: center;
}

.drawer-close:hover {
  color: var(--ink);
  background: #e9eaec;
}

.drawer-close:focus-visible {
  outline: 3px solid rgba(244, 119, 33, 0.24);
  outline-offset: 2px;
}

.drawer-content {
  display: grid;
  gap: 12px;
  padding: 16px 18px 28px;
}

.drawer-loading,
.drawer-error {
  min-height: 260px;
  padding: 40px 24px;
}

.drawer-loading {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
}

.drawer-spinner {
  width: 17px;
  height: 17px;
  border: 2px solid #d9dbdf;
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.drawer-error {
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
}

.drawer-error strong {
  font-size: 15px;
}

.drawer-error p {
  margin: 7px 0 16px;
  color: var(--muted);
  font-size: 11px;
}

.drawer-section {
  padding: 17px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

.drawer-section-heading {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.drawer-section-heading h3 {
  margin: 0;
  font-size: 13px;
  letter-spacing: -0.015em;
}

.drawer-section-note {
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-list {
  display: grid;
}

.detail-list > div {
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  border-bottom: 1px solid var(--line);
}

.detail-list > div:last-child {
  border-bottom: 0;
}

.detail-list span {
  color: var(--muted);
  font-size: 10px;
}

.detail-list strong {
  color: var(--ink-2);
  font-size: 10px;
  font-weight: 630;
  text-align: right;
}

.detail-metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin-top: 13px;
  overflow: hidden;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 9px;
}

.detail-metric-grid > div {
  min-width: 0;
  padding: 12px;
  background: #fff;
}

.detail-metric-grid span,
.detail-split-grid span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 9px;
}

.detail-metric-grid strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.detail-metric-grid-six {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.detail-split-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 13px;
}

.detail-split-grid article {
  padding: 13px;
  background: #fafafa;
  border: 1px solid var(--line);
  border-radius: 9px;
}

.detail-split-grid strong {
  display: block;
  color: var(--ink);
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.detail-split-grid small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 9px;
}

.platform-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.platform-tags span {
  padding: 5px 8px;
  color: var(--ink-2);
  font-size: 9px;
  background: #f2f3f4;
  border-radius: 6px;
}

.platform-tags .is-empty {
  color: var(--muted);
  background: transparent;
}

.detail-model-list {
  margin-top: 13px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 9px;
}

.detail-model-list-head,
.detail-model-row {
  display: grid;
  grid-template-columns: minmax(150px, 0.8fr) minmax(240px, 1.6fr);
  gap: 16px;
  align-items: center;
  padding: 10px 12px;
}

.detail-model-list-head {
  color: var(--muted);
  font-size: 9px;
  font-weight: 680;
  background: #fafafa;
  border-bottom: 1px solid var(--line);
}

.detail-model-list-head span:last-child {
  text-align: right;
}

.detail-model-row {
  border-bottom: 1px solid var(--line);
}

.detail-model-row:last-child {
  border-bottom: 0;
}

.detail-model-row strong {
  overflow: hidden;
  color: var(--ink-2);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-model-row span {
  color: var(--muted);
  font-size: 9px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.detail-model-row.is-negative-margin {
  background: var(--danger-bg);
}

.detail-inline-empty {
  padding: 22px 12px;
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}

.page-footer {
  display: flex;
  gap: 14px;
  justify-content: space-between;
  max-width: 1480px;
  padding-top: 18px;
  margin: 0 auto;
  color: var(--muted-2);
  font-size: 9px;
  border-top: 1px solid var(--line);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1180px) {
  .metric-grid-four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .overview-secondary-grid {
    grid-template-columns: 1fr;
  }

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

  .snapshot-list > div {
    display: grid;
    grid-template-columns: 1fr;
    border-top: 0;
    border-right: 1px solid var(--line);
  }

  .snapshot-list > div:last-child {
    border-right: 0;
  }
}

@media (max-width: 880px) {
  :root {
    --sidebar-width: 100%;
  }

  .admin-app {
    padding-top: 116px;
  }

  .sidebar {
    right: 0;
    bottom: auto;
    width: 100%;
    height: 116px;
    padding: 12px 16px 10px;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  }

  .sidebar-brand {
    padding: 0 2px 9px;
  }

  .brand-mark-small {
    width: 32px;
    height: 32px;
    padding-top: 10px;
    font-size: 9px;
    border-radius: 9px;
  }

  .sidebar-brand > span:last-child small,
  .nav-group-label,
  .session-state {
    display: none;
  }

  .sidebar-nav {
    display: flex;
    gap: 5px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .sidebar-nav::-webkit-scrollbar {
    display: none;
  }

  .nav-link {
    flex: 0 0 auto;
    min-height: 36px;
    padding: 0 10px;
    font-size: 11px;
  }

  .nav-link svg {
    display: none;
  }

  .nav-link.is-active {
    box-shadow: inset 0 -2px var(--brand);
  }

  .sidebar-footer {
    position: absolute;
    top: 14px;
    right: 16px;
  }

  .sidebar-footer .button {
    width: auto;
    min-height: 32px;
    padding: 0 10px;
  }

  .main-content {
    width: 100%;
    margin-left: 0;
    padding: 23px 20px 30px;
  }
}

@media (max-width: 680px) {
  .login-view {
    padding: 18px;
  }

  .login-card {
    padding: 28px 22px;
  }

  .main-content {
    padding: 20px 14px 26px;
  }

  .topbar,
  .section-heading {
    align-items: flex-start;
  }

  .topbar {
    margin-bottom: 20px;
  }

  .page-subtitle,
  .refresh-meta,
  .section-note {
    display: none;
  }

  .topbar .button {
    min-width: 40px;
    padding: 0 10px;
  }

  .topbar .button > span:last-child {
    display: none;
  }

  .section-heading-actions {
    display: grid;
  }

  .filter-form {
    width: 100%;
    justify-content: flex-start;
  }

  .user-search-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
  }

  .filter-field-search {
    min-width: 0;
  }

  .search-field {
    width: 100%;
  }

  .metric-grid-four,
  .metric-grid-three {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-card {
    padding: 14px;
  }

  .metric-value {
    font-size: 24px;
  }

  .chart-legend {
    display: none;
  }

  .panel-heading-with-filters {
    display: grid;
  }

  .finance-filter-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .snapshot-list {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .snapshot-list > div {
    grid-template-columns: 1fr auto;
    border-top: 1px solid var(--line);
    border-right: 0;
  }

  .unavailable-panel {
    align-items: flex-start;
  }

  .detail-metric-grid,
  .detail-metric-grid-six {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pagination-bar {
    align-items: flex-start;
  }
}

@media (max-width: 430px) {
  .metric-grid-four,
  .metric-grid-three {
    grid-template-columns: 1fr;
  }

  .user-search-form,
  .finance-filter-form {
    grid-template-columns: 1fr 1fr;
  }

  .user-search-form .filter-field-search,
  .finance-filter-form .filter-field {
    grid-column: 1 / -1;
  }

  .pagination-bar,
  .unavailable-panel {
    display: grid;
  }

  .detail-drawer {
    width: 100vw;
  }

  .drawer-header {
    padding: 20px 18px 16px;
  }

  .drawer-content {
    padding-inline: 10px;
  }

  .detail-split-grid {
    grid-template-columns: 1fr;
  }

  .detail-model-list-head,
  .detail-model-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .detail-model-list-head span:last-child,
  .detail-model-row span {
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
