:root {
  color-scheme: dark;
  --bg: #172132;
  --panel: #1d293d;
  --panel-2: #202d42;
  --panel-3: #263650;
  --text: #f7f9fd;
  --muted: #9fadbf;
  --line: #30425f;
  --blue: #3c82f6;
  --green: #20c997;
  --orange: #ff8a1f;
  --purple: #9b5cf6;
  --cyan: #22d3ee;
  --lime: #86c916;
  --pink: #ec4899;
  --bad: #f87171;
  --warn: #f59e0b;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 96% 0%, rgb(32 201 151 / 24%), transparent 22rem),
    radial-gradient(circle at 0% 100%, rgb(34 211 238 / 16%), transparent 20rem),
    linear-gradient(rgb(255 255 255 / 2%) 1px, transparent 1px),
    linear-gradient(90deg, rgb(255 255 255 / 2%) 1px, transparent 1px),
    #071023;
  background-size: auto, auto, 80px 80px, 80px 80px, auto;
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell {
  width: min(1440px, calc(100vw - 32px));
  margin: 0 auto 32px;
}

h1, h2, p { margin: 0; }
h1 { font-size: 28px; line-height: 1.2; font-weight: 780; }
h2 { font-size: 18px; line-height: 1.25; font-weight: 760; }
.eyebrow {
  margin-bottom: 8px;
  color: #8fc2ff;
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0;
  text-transform: uppercase;
}
.muted, .message, .small { color: var(--muted); }
.small { margin-top: 5px; font-size: 13px; line-height: 1.45; }
.label { color: #b7c2d1; font-size: 15px; }
.warn-text { color: var(--orange); }
.blue-text { color: #7ea6ff; }

.app-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 18px 50px rgb(0 0 0 / 20%);
}

.login-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 44px 18px;
}

.login-brand {
  display: grid;
  justify-items: center;
  gap: 10px;
  margin-bottom: 28px;
  text-align: center;
}
.brand-logo {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  box-shadow: 0 0 28px rgb(32 201 151 / 34%);
}
.login-brand h1 {
  color: #18bba6;
  font-size: 34px;
  letter-spacing: 0;
  text-shadow: 0 0 22px rgb(32 201 151 / 28%);
}
.login-brand p {
  color: #8da0b8;
  font-size: 15px;
}
.login-form, .filters, .actions { display: flex; gap: 12px; }
.login-form { flex-direction: column; }
.auth-card {
  width: min(450px, 100%);
  padding: 32px;
  border: 1px solid rgb(143 162 190 / 16%);
  border-radius: 16px;
  background: rgb(29 41 61 / 88%);
  box-shadow: 0 24px 70px rgb(0 0 0 / 30%);
  backdrop-filter: blur(14px);
}
.auth-title {
  margin-bottom: 14px;
  text-align: center;
}
.auth-title h2 {
  font-size: 28px;
}
.auth-title p {
  margin-top: 8px;
  color: var(--muted);
}

label { display: grid; gap: 7px; color: var(--muted); font-size: 14px; }
input, select, button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #182338;
  color: var(--text);
  font: inherit;
  padding: 0 12px;
}
.auth-field { gap: 9px; }
.auth-field > span {
  color: #c8d3e0;
  font-size: 14px;
  font-weight: 650;
}
.input-wrap {
  display: flex;
  align-items: center;
  min-height: 46px;
  border: 1px solid #3a4a63;
  border-radius: 12px;
  background: #1c2739;
  transition: border-color .16s ease, box-shadow .16s ease;
}
.input-wrap:focus-within {
  border-color: #20c9b7;
  box-shadow: 0 0 0 3px rgb(32 201 183 / 12%);
}
.input-icon {
  width: 42px;
  color: #74849a;
  text-align: center;
  font-weight: 780;
}
.input-wrap input {
  flex: 1;
  min-height: 44px;
  border: 0;
  background: transparent;
  padding: 0 12px 0 0;
  outline: 0;
}
.input-wrap input::placeholder { color: #74849a; }

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 28px;
}
.check-row input {
  width: 16px;
  height: 16px;
  min-height: 0;
  padding: 0;
  accent-color: var(--blue);
}

button {
  cursor: pointer;
  background: var(--blue);
  border-color: var(--blue);
  color: white;
  font-weight: 720;
}
.login-submit {
  min-height: 48px;
  margin-top: 10px;
  border-color: #19b8aa;
  background: #19b8aa;
  border-radius: 12px;
  box-shadow: 0 10px 24px rgb(25 184 170 / 28%);
}
.login-submit:hover {
  background: #20c9b7;
  border-color: #20c9b7;
}
.login-footnote {
  margin-top: 24px;
  color: #8da0b8;
  font-size: 14px;
}
.login-copyright {
  margin-top: 32px;
  color: #53657e;
  font-size: 13px;
}
button:disabled { cursor: progress; opacity: .65; }
button.ghost { background: transparent; color: var(--text); }

.app-panel {
  min-height: 100vh;
  padding: 24px 26px 34px;
  border-top: 0;
  border-bottom: 0;
}

.topbar, .section-head, .chart-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.topbar {
  margin: -24px -26px 8px;
  padding: 24px 26px;
  border-bottom: 1px solid var(--line);
}
.section-head { margin: 28px 0 14px; }
.section-head .muted { margin-top: 5px; }
.actions { align-items: center; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
  margin: 8px 0 30px;
}

.metric-card, .info-card, .account-card, .chart-card, .details-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-2);
}

.metric-card {
  position: relative;
  min-height: 172px;
  padding: 28px 22px;
  overflow: hidden;
}
.metric-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(145deg, transparent 35%, rgb(255 255 255 / 5%));
  pointer-events: none;
}
.metric-card strong {
  display: block;
  margin-top: 20px;
  font-size: 34px;
  line-height: 1;
  font-weight: 820;
}
.metric-card.accent-green { border-color: rgb(32 201 151 / 32%); background: linear-gradient(135deg, #173545, #263a51); }
.metric-card.accent-blue { border-color: rgb(60 130 246 / 38%); background: linear-gradient(135deg, #1d3151, #2b3b5a); }
.metric-card.accent-orange { border-color: rgb(255 138 31 / 34%); background: linear-gradient(135deg, #2c3140, #3b3542); }
.metric-card.accent-purple { border-color: rgb(155 92 246 / 38%); background: linear-gradient(135deg, #262e51, #342e57); }

.overview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.info-card {
  padding: 20px;
  min-height: 188px;
}
.info-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 820;
}
.badge.cyan { color: var(--cyan); background: rgb(34 211 238 / 12%); }
.badge.orange { color: var(--orange); background: rgb(255 138 31 / 14%); }
.badge.indigo { color: #7c83ff; background: rgb(124 131 255 / 14%); }
.badge.teal { color: var(--green); background: rgb(32 201 151 / 12%); }
.badge.pink { color: var(--pink); background: rgb(236 72 153 / 14%); }
.badge.lime { color: var(--lime); background: rgb(134 201 22 / 14%); }

dl { margin: 0; display: grid; gap: 12px; }
dl div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}
dt { color: var(--muted); }
dd {
  margin: 0;
  color: var(--text);
  font-size: 20px;
  font-weight: 780;
  text-align: right;
}

.filters { margin-bottom: 16px; }
.filters input { flex: 1; min-width: 280px; }
.filters select { min-width: 136px; }

.account-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.account-card {
  padding: 18px;
  min-height: 244px;
}
.account-card.warn { border-color: rgb(245 158 11 / 50%); }
.account-card.bad { border-color: rgb(248 113 113 / 55%); }
.account-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.account-card-head strong {
  display: block;
  font-size: 18px;
  line-height: 1.3;
}
.account-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}
.account-meta span {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #dbe5f2;
  background: rgb(255 255 255 / 3%);
  font-size: 13px;
}

.quota-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  color: var(--muted);
}
.quota-row strong {
  color: var(--text);
  font-size: 28px;
}
.budget-bar {
  --used: 0%;
  --allowed: 100%;
  --meter-color: var(--green);
  position: relative;
  height: 12px;
  margin: 10px 0;
  border-radius: 999px;
  background: linear-gradient(to right, var(--meter-color) 0 calc(100% - var(--used)), #3a4658 calc(100% - var(--used)) 100%);
  overflow: hidden;
}
.budget-bar.warn { --meter-color: var(--warn); }
.budget-bar.bad { --meter-color: var(--bad); }
.budget-marker {
  position: absolute;
  top: -4px;
  bottom: -4px;
  left: calc(100% - var(--allowed));
  width: 2px;
  background: white;
  opacity: .85;
}
.budget-note {
  display: grid;
  gap: 4px;
  min-height: 46px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgb(255 255 255 / 4%);
  color: var(--muted);
  font-size: 13px;
}
.budget-note span:first-child {
  color: var(--text);
  font-weight: 780;
}
.budget-note.warn span:first-child { color: var(--warn); }
.budget-note.bad span:first-child { color: var(--bad); }
.card-stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.card-stats div {
  display: block;
  min-width: 0;
}
.card-stats dt { font-size: 12px; }
.card-stats dd {
  margin-top: 4px;
  font-size: 14px;
  text-align: left;
  overflow-wrap: anywhere;
}

.pill, .budget-label {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #2b3850;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  white-space: nowrap;
}
.pill.normal, .budget-label.normal { color: var(--green); }
.pill.limited, .budget-label.warn { color: var(--warn); }
.pill.error, .pill.banned, .budget-label.bad { color: var(--bad); }
.pill.disabled { color: var(--muted); }
.expiry { font-weight: 760; }
.expiry.normal { color: var(--green); }
.expiry.warn { color: var(--warn); }
.expiry.bad { color: var(--bad); }

.chart-card {
  margin-top: 30px;
  padding: 20px;
}
.chart-head { align-items: center; margin-bottom: 14px; }
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: #dce6f3;
  font-size: 13px;
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i {
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-radius: 999px;
}
.legend-cost { color: var(--blue); }
.legend-user { color: var(--green); }
.legend-requests { color: var(--orange); }
.chart {
  min-height: 340px;
  overflow: hidden;
}
.chart svg {
  display: block;
  width: 100%;
  height: auto;
}
.grid-line { stroke: #3a4962; stroke-width: 1; }
.axis-line { stroke: #51627c; stroke-width: 1; }
.axis-text { fill: #8fa0b4; font-size: 12px; }
.axis-text.orange { fill: var(--orange); }
.trend-line {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.cost-line { stroke: var(--blue); }
.user-line { stroke: var(--green); stroke-dasharray: 7 8; }
.request-line { stroke: var(--orange); stroke-width: 3; }
.cost-dot { fill: var(--blue); stroke: var(--panel); stroke-width: 2; }

.details-card {
  margin-top: 24px;
  padding: 0;
  overflow: hidden;
}
.details-card summary {
  cursor: pointer;
  padding: 16px 18px;
  font-weight: 760;
}
.details-card > .muted { padding: 0 18px 12px; }
.table-wrap {
  overflow: auto;
  border-top: 1px solid var(--line);
  background: #172238;
}
table { width: 100%; border-collapse: collapse; min-width: 1180px; }
th, td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}
th {
  position: sticky;
  top: 0;
  background: #202d42;
  color: var(--muted);
  z-index: 1;
  font-weight: 720;
}
tr:last-child td { border-bottom: 0; }
tbody tr.high-risk { background: rgb(248 113 113 / 7%); }
tbody tr.medium-risk { background: rgb(245 158 11 / 6%); }
.account-name { font-weight: 760; }
.cost { font-weight: 720; }
.empty, .empty-card {
  padding: 24px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 14px;
}

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

@media (max-width: 760px) {
  .shell { width: min(100vw - 18px, 720px); }
  .login-panel { min-height: 100vh; padding: 28px 10px; }
  .auth-card { padding: 24px 18px; }
  .login-brand { margin-bottom: 22px; }
  .app-panel { padding: 20px 14px 24px; }
  .topbar {
    margin: -20px -14px 8px;
    padding: 20px 14px;
  }
  .topbar, .filters, .actions, .chart-head { flex-direction: column; }
  .actions { width: 100%; }
  .actions button { width: 100%; }
  .metric-grid, .overview-grid, .account-grid { grid-template-columns: 1fr; gap: 12px; }
  .metric-card { min-height: 132px; padding: 20px; }
  .filters input, .filters select { width: 100%; min-width: 0; }
  .card-stats { grid-template-columns: 1fr; }
  .legend { align-items: flex-start; }
  table, thead, tbody, tr, th, td { display: block; min-width: 0; }
  thead { display: none; }
  .table-wrap { overflow: visible; }
  tbody { display: grid; gap: 12px; padding: 12px; }
  tr {
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
  }
  td {
    display: grid;
    grid-template-columns: 118px 1fr;
    gap: 12px;
    border-bottom: 1px solid var(--line);
  }
  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 720;
  }
}
