*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --page:    #F2EEF9;
  --surface: #FFFFFF;
  --border:  #DDD5EC;
  --border2: #EDE8F5;
  --text:    #12082A;
  --text2:   #5C5373;
  --text3:   #A499BA;
  --purple:  #8B2FD8;
  --purple-d:#7020BB;
  --purple-l:#F4EFFE;
  --pink:    #D63891;
  --grad:    linear-gradient(135deg, #8B2FD8 0%, #D63891 100%);
  --green:   #16A34A;
  --r:       6px;
}

html { -webkit-font-smoothing: antialiased; scrollbar-gutter: stable; }

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--page);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Header ─────────────────────────────── */
.header {
  position: sticky; top: 0; z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1440px; margin: 0 auto;
  padding: 0 32px; height: 56px;
  display: flex; align-items: center; gap: 20px;
}
.header-brand {
  font-size: 15px; font-weight: 700;
  color: var(--text); letter-spacing: -0.4px;
}
.header-brand span { background: var(--grad); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.header-sep { width: 1px; height: 18px; background: var(--border); }
.header-sub { font-size: 12px; color: var(--text3); }
.hright { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.live-wrap { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text2); }
.live-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--green);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.45} }
.btn-refresh {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 12px; border: 1px solid var(--border);
  border-radius: var(--r); background: var(--surface);
  color: var(--text2); font-size: 12px; font-weight: 500;
  cursor: pointer; font-family: inherit;
  transition: border-color .15s, color .15s, background .15s;
}
.btn-refresh:hover { border-color: var(--purple); color: var(--purple); background: var(--purple-l); }
.btn-refresh:disabled { opacity: .6; cursor: not-allowed; pointer-events: none; }
.btn-refresh.loading svg { animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Filter Bar ─────────────────────────── */
.filter-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
}
.filter-bar-inner {
  max-width: 1440px; margin: 0 auto;
  height: 42px; display: flex; align-items: center; gap: 10px;
}
.filter-label {
  font-size: 11px; font-weight: 600;
  letter-spacing: .07em; text-transform: uppercase;
  color: var(--text3); white-space: nowrap;
}
.filter-select {
  padding: 5px 28px 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--page);
  color: var(--text2);
  font-size: 13px; font-weight: 500; font-family: inherit;
  cursor: pointer; appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23A499BA' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
  min-width: 200px; max-width: 340px;
  transition: border-color .15s, background .15s, color .15s;
}
.filter-select:hover, .filter-select:focus { border-color: var(--purple); outline: none; }
.filter-select.filter-active {
  border-color: var(--purple); color: var(--purple);
  background-color: var(--purple-l);
}
.filter-sep {
  width: 1px; height: 18px;
  background: var(--border);
  margin: 0 4px;
}
.filter-badge {
  font-size: 11px; font-weight: 600;
  color: var(--purple); background: var(--purple-l);
  border: 1px solid #D8C0F5; border-radius: 20px;
  padding: 2px 10px; white-space: nowrap;
}

/* ── Tabs ───────────────────────────────── */
.tabbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; padding: 0 32px;
  overflow-x: auto; gap: 0;
}
.tabbar::-webkit-scrollbar { display: none; }
.tab {
  position: relative; padding: 11px 18px;
  font-size: 13px; font-weight: 500;
  color: var(--text3); cursor: pointer;
  white-space: nowrap; user-select: none;
  transition: color .15s;
}
.tab::after {
  content: ''; position: absolute;
  bottom: -1px; left: 0; right: 0;
  height: 2px; border-radius: 2px 2px 0 0;
  background: var(--grad);
  transform: scaleX(0); transition: transform .2s;
}
.tab:hover { color: var(--text2); }
.tab.active { color: var(--purple); }
.tab.active::after { transform: scaleX(1); }

/* ── Page wrapper ───────────────────────── */
.page { max-width: 1440px; margin: 0 auto; padding: 28px 32px 56px; }
.view { display: none; }
.view.active { display: block; }

/* ── Section label ──────────────────────── */
.sec-row { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; margin-top: 32px; }
.sec-row:first-child { margin-top: 0; }
.sec-dot { width: 8px; height: 8px; border-radius: 2px; background: var(--grad); flex-shrink: 0; }
.sec-label { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text2); }

/* ── KPI strip ──────────────────────────── */
.kpi-row {
  display: grid; grid-template-columns: repeat(4,1fr);
  gap: 2px; background: var(--border);
  border: 1px solid var(--border); border-radius: var(--r);
  overflow: hidden; margin-bottom: 28px;
}
.kpi { background: var(--surface); padding: 22px 24px 20px; position: relative; }
.kpi::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--grad); opacity: 0; transition: opacity .2s;
}
.kpi:hover::before { opacity: 1; }
.kpi-label { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text3); margin-bottom: 10px; }
.kpi-val { font-size: 32px; font-weight: 800; color: var(--text); letter-spacing: -1.5px; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi-note { font-size: 11px; color: var(--text3); margin-top: 6px; }

/* ── Layout grids ───────────────────────── */
.g-6040 { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; }
.g-half { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── Panel ──────────────────────────────── */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }
.panel-hd { padding: 16px 20px 14px; border-bottom: 1px solid var(--border2); display: flex; align-items: flex-start; justify-content: space-between; }
.panel-title { font-size: 13px; font-weight: 600; color: var(--text); }
.panel-desc  { font-size: 12px; color: var(--text3); margin-top: 1px; }
.panel-body  { padding: 20px; }

/* ── Chart containers ───────────────────── */
.ch-wrap { position: relative; }
.ch-280 { height: 280px; } .ch-220 { height: 220px; } .ch-260 { height: 260px; } .ch-360 { height: 360px; }

/* ── Donut legend ───────────────────────── */
.dlegend { display: flex; flex-direction: column; gap: 8px; padding: 0 20px 18px; }
.dleg-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.dleg-swatch { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.dleg-name { flex: 1; color: var(--text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.dleg-val { font-size: 12px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }

/* ── Data table ─────────────────────────── */
.dtable { width: 100%; border-collapse: collapse; table-layout: fixed; }
.dtable thead th {
  font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  color: var(--text3); padding: 9px 16px; text-align: right;
  background: #FAF8FD; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.dtable thead th:first-child { text-align: left; }
.dtable tbody td {
  padding: 10px 16px; font-size: 13px; color: var(--text2); text-align: right;
  border-bottom: 1px solid var(--border2); font-variant-numeric: tabular-nums; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.dtable tbody td:first-child { text-align: left; color: var(--text); font-weight: 500; }
.dtable tbody tr:last-child td { border-bottom: none; }
.dtable tbody tr:nth-child(even) td { background: #FDFBFF; }
.dtable tbody tr:hover td { background: var(--purple-l); }

/* ── Provider blocks ────────────────────── */
.pblock { border-top: 1px solid var(--border2); }
.pblock:first-child { border-top: none; }
.pblock-hd { display: flex; align-items: center; gap: 10px; padding: 14px 20px 10px; }
.pbadge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 4px; font-size: 11px; font-weight: 600; letter-spacing: .03em; }
.pcount { font-size: 11px; color: var(--text3); }

/* ── User list ──────────────────────────── */
.ulist { padding: 0 20px; }
.ulist-hd {
  display: grid; grid-template-columns: 28px 1fr 100px 78px; gap: 12px;
  padding: 0 0 9px; border-bottom: 1px solid var(--border);
  font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text3);
}
.urow { display: grid; grid-template-columns: 28px 1fr 100px 78px; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border2); }
.urow:last-child { border-bottom: none; }
.uavatar { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: #fff; flex-shrink: 0; }
.uinfo-name { font-size: 13px; font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ubar-track { height: 3px; background: var(--border2); border-radius: 2px; margin-top: 5px; overflow: hidden; }
.ubar-fill { height: 100%; border-radius: 2px; background: var(--grad); transition: width .7s ease; }
.utok { font-size: 13px; font-weight: 600; color: var(--text); text-align: right; font-variant-numeric: tabular-nums; }
.ureqs { font-size: 11px; color: var(--text3); text-align: right; }

/* ── Model cards (Models tab) ───────────── */
.model-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.mc-sec-hd {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 8px;
  padding: 20px 0 6px;
  border-top: 1px solid var(--border2);
}
.mc-sec-hd.first { border-top: none; padding-top: 0; }

.mcard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  transition: box-shadow .2s, border-color .2s;
}
.mcard:hover { border-color: #C4A8E8; box-shadow: 0 4px 16px rgba(139,47,216,.1); }

.mcard-bar { height: 4px; background: var(--grad); }

.mcard-body { padding: 20px 22px; }

.mcard-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 16px; gap: 8px; }

.mcard-name { font-size: 14px; font-weight: 700; color: var(--text); word-break: break-all; }

.mcard-center { text-align: center; margin-bottom: 18px; padding: 14px 0; background: var(--purple-l); border-radius: 6px; }
.mcard-total { font-size: 44px; font-weight: 800; color: var(--purple); letter-spacing: -2.5px; line-height: 1; font-variant-numeric: tabular-nums; }
.mcard-total-label { font-size: 11px; font-weight: 500; color: var(--text3); letter-spacing: .05em; text-transform: uppercase; margin-top: 4px; }
.mcard-pct { display: inline-block; margin-top: 6px; padding: 2px 8px; background: rgba(139,47,216,.12); color: var(--purple); border-radius: 20px; font-size: 11px; font-weight: 600; }

.mcard-io { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.io-row { display: flex; align-items: center; gap: 8px; }
.io-name { font-size: 11px; font-weight: 500; color: var(--text3); width: 46px; flex-shrink: 0; }
.io-track { flex: 1; height: 6px; background: var(--border2); border-radius: 3px; overflow: hidden; }
.io-fill-in  { height: 100%; border-radius: 3px; background: var(--purple); }
.io-fill-out { height: 100%; border-radius: 3px; background: var(--pink); }
.io-val { font-size: 12px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; width: 52px; text-align: right; flex-shrink: 0; }

.mcard-limits { display: flex; gap: 12px; margin-bottom: 12px; font-size: 11px; color: var(--text3); }
.mlimit-item strong { color: var(--text2); font-weight: 600; }

.mcard-footer { padding-top: 14px; border-top: 1px solid var(--border2); display: flex; align-items: center; justify-content: space-between; }
.mcard-req { font-size: 12px; color: var(--text2); }
.mcard-req strong { color: var(--text); font-weight: 600; }

/* ── Filter right (user search) ────────── */
.filter-right {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
  padding-left: 14px;
  border-left: 1px solid var(--border);
}

/* ── Filter input (user search) ─────────── */
.filter-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.filter-search-ico {
  position: absolute;
  left: 9px;
  color: var(--text3);
  pointer-events: none;
  flex-shrink: 0;
  transition: color .15s;
}
.filter-input-wrap:focus-within .filter-search-ico { color: var(--purple); }

.filter-input {
  padding: 5px 28px 5px 30px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--page);
  color: var(--text2);
  font-size: 13px; font-weight: 500; font-family: inherit;
  min-width: 220px; max-width: 340px;
  transition: border-color .15s, background .15s, color .15s, box-shadow .15s;
  outline: none;
}
.filter-input:hover { border-color: #C4A8E8; }
.filter-input:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(139,47,216,.1);
}
.filter-input.filter-active {
  border-color: var(--purple); color: var(--purple); background-color: var(--purple-l);
}
.filter-input::placeholder { color: var(--text3); font-weight: 400; }

.filter-clear-btn {
  position: absolute; right: 7px;
  display: flex; align-items: center; justify-content: center;
  width: 18px; height: 18px;
  border: none; border-radius: 50%;
  background: var(--border);
  color: var(--text3);
  cursor: pointer;
  transition: background .15s, color .15s;
  padding: 0;
}
.filter-clear-btn:hover { background: #C4A8E8; color: var(--purple); }

.btn-user-dash {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 12px;
  border: none; border-radius: var(--r);
  background: var(--grad);
  color: #fff;
  font-size: 12px; font-weight: 600; font-family: inherit;
  cursor: pointer; white-space: nowrap;
  transition: opacity .15s, box-shadow .15s;
  box-shadow: 0 1px 4px rgba(139,47,216,.25);
}
.btn-user-dash:hover { opacity: .88; box-shadow: 0 2px 8px rgba(139,47,216,.35); }

/* ── Users tab ──────────────────────────── */
.users-tab-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.user-big-list { padding: 0 22px 6px; }
.user-big-hd {
  display: grid; grid-template-columns: 32px 40px 1fr 110px 90px 28px; gap: 12px;
  padding: 0 0 10px; border-bottom: 1px solid var(--border);
  font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text3);
}
.user-big-row {
  display: grid; grid-template-columns: 32px 40px 1fr 110px 90px 28px; gap: 12px;
  align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border2);
}
.user-big-row:last-child { border-bottom: none; }

.ubig-dash-link {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border: 1px solid var(--border); border-radius: var(--r);
  color: var(--text3);
  text-decoration: none;
  transition: border-color .15s, color .15s, background .15s;
}
.ubig-dash-link:hover { border-color: var(--purple); color: var(--purple); background: var(--purple-l); }
.ubig-rank { font-size: 13px; font-weight: 700; color: var(--text3); text-align: right; font-variant-numeric: tabular-nums; }
.ubig-av { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0; }
.ubig-name { font-size: 13px; font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ubig-bar-wrap { margin-top: 5px; }
.ubig-bar-track { height: 4px; background: var(--border2); border-radius: 2px; overflow: hidden; }
.ubig-bar-fill { height: 100%; border-radius: 2px; background: var(--grad); transition: width .7s; }
.ubig-tok { font-size: 14px; font-weight: 700; color: var(--text); text-align: right; font-variant-numeric: tabular-nums; }
.ubig-req { font-size: 12px; color: var(--text3); text-align: right; }

/* ── Stacked chart legend ───────────────── */
.monthly-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; padding: 14px 20px; border-top: 1px solid var(--border2); }
.ml-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text2); }
.ml-dot { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }

/* ── Placeholder ────────────────────────── */
.ph { display: flex; align-items: center; justify-content: center; min-height: 80px; font-size: 13px; color: var(--text3); }

/* ── Responsive ─────────────────────────── */
@media (max-width: 1100px) {
  .g-6040, .g-half, .users-tab-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .page, .header-inner, .tabbar { padding-left: 16px; padding-right: 16px; }
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .kpi-val { font-size: 24px; }
  .model-cards { grid-template-columns: 1fr; }
}
