:root {
  color-scheme: dark;
  --bg: #15191f;
  --panel: #191d23;
  --panel-2: #1b2028;
  --line: #444b58;
  --line-soft: #273541;
  --text: #d9dee7;
  --strong: #f4f7fb;
  --muted: #8e96a5;
  --blue: #3898ff;
  --green: #55d392;
  --cyan: #63d8e5;
  --yellow: #f0c36a;
  --orange: #e58a32;
  --red: #ef5350;
  --ink: #0d1117;
  --violet: #7785ff;
  --radius: 8px;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-2: #f2f6fb;
  --line: #d5dce7;
  --line-soft: #e5ebf3;
  --text: #273142;
  --strong: #101722;
  --muted: #697586;
  --blue: #1677d2;
  --green: #1f9d63;
  --cyan: #0e9aaa;
  --yellow: #b87912;
  --orange: #bd671a;
  --red: #cf3f3f;
  --ink: #ffffff;
  --violet: #5968dd;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="light"] body {
  background: var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 46px;
  border: 1px solid rgba(99, 216, 229, .45);
  border-radius: var(--radius);
  padding: 0 18px;
  background: rgba(99, 216, 229, .10);
  color: var(--cyan);
  font-weight: 700;
  cursor: pointer;
}

.icon-button {
  position: relative;
  width: 46px;
  min-width: 46px;
  padding: 0;
}

.icon-button::before {
  content: "";
  position: absolute;
  inset: 12px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.icon-button[data-icon="sun"]::after {
  content: "";
  position: absolute;
  inset: 8px;
  border: 2px dotted currentColor;
  border-radius: 50%;
}

.icon-button[data-icon="moon"]::before {
  border: 0;
  background: currentColor;
  box-shadow: -7px 0 0 2px var(--panel);
  transform: translateX(5px);
}

button.secondary {
  border-color: rgba(56, 152, 255, .55);
  background: rgba(56, 152, 255, .12);
  color: #7fc0ff;
}

:root[data-theme="light"] button.secondary {
  color: #125ea6;
}

button.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
}

:root[data-theme="light"] button.ghost {
  background: rgba(255, 255, 255, .65);
  color: var(--strong);
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px;
  background: #12161c;
  color: var(--text);
}

:root[data-theme="light"] input,
:root[data-theme="light"] select {
  background: #ffffff;
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 17px, calc(100% - 12px) 17px;
  background-repeat: no-repeat;
  background-size: 5px 5px, 5px 5px;
  padding-right: 34px;
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.hidden {
  display: none !important;
}

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

.login-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-panel {
  display: grid;
  gap: 22px;
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 28px;
  background: var(--panel);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-lockup img {
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
  border: 1px solid rgba(32, 213, 200, .35);
  border-radius: 8px;
  object-fit: cover;
}

.brand-lockup strong {
  display: block;
  font-size: 18px;
}

.brand-lockup-login img {
  width: 72px;
  height: 72px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.client-title {
  margin: 0;
  color: var(--strong);
  font-size: 22px;
  font-weight: 800;
  line-height: 1.15;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(26px, 3vw, 36px);
  letter-spacing: 0;
  color: var(--strong);
}

h2 {
  margin-bottom: 10px;
  font-size: 18px;
}

.muted {
  color: var(--muted);
}

.error {
  min-height: 20px;
  margin: 0;
  color: var(--red);
}

.dashboard-view {
  display: block;
  min-height: 100vh;
  width: 100%;
  margin: 0;
  padding: 0;
}

.content-shell {
  display: grid;
  gap: 28px;
  width: min(1560px, 100%);
  min-width: 0;
  margin: 0 auto;
  padding: 34px 36px 42px;
}

.topbar,
.panel-header,
.dialog-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex: 0 0 auto;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.topbar-brand img {
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  border: 1px solid rgba(99, 216, 229, .35);
  border-radius: 8px;
  object-fit: cover;
}

.status-line {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: #171b21;
  color: var(--muted);
}

:root[data-theme="light"] .status-line {
  background: #ffffff;
}

.dashboard-section {
  display: grid;
  gap: 14px;
}

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

.metric {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 104px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 22px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .018), transparent), var(--panel);
}

.metric > div {
  min-width: 0;
}

.metric span {
  color: var(--muted);
}

.metric strong {
  align-self: end;
  color: var(--strong);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 28px;
}

.metric-icon {
  display: inline-grid;
  width: 56px;
  height: 56px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 18px;
  background: color-mix(in srgb, currentColor 18%, transparent);
  font-size: 13px;
  font-weight: 900;
}

.metric-blue .metric-icon {
  color: var(--blue);
}

.metric-green .metric-icon {
  color: var(--green);
}

.metric-cyan .metric-icon {
  color: var(--cyan);
}

.metric-orange .metric-icon {
  color: var(--orange);
}

.workspace {
  min-width: 0;
  max-width: 100%;
}

.users-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  min-width: 0;
  max-width: 100%;
}

.users-panel {
  overflow: hidden;
}

.panel-header {
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.filters-bar {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr)) minmax(210px, 1.2fr) auto;
  gap: 12px;
  align-items: end;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: #14191f;
}

:root[data-theme="light"] .filters-bar {
  background: #f7f9fc;
}

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

.table-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .015);
}

:root[data-theme="light"] .table-meta {
  background: #fbfcfe;
}

#table-count {
  font-weight: 800;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

table {
  width: max(100%, 980px);
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: rgba(99, 216, 229, .055);
}

.badge {
  display: inline-flex;
  min-width: 76px;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
}

.badge.active {
  background: rgba(85, 211, 146, .14);
  color: var(--green);
}

.badge.disabled,
.badge.expired {
  background: rgba(255, 122, 138, .14);
  color: var(--red);
}

.badge.limited {
  background: rgba(240, 195, 106, .14);
  color: var(--yellow);
}

.usage-bar {
  width: 150px;
  height: 6px;
  overflow: hidden;
  margin: 7px 0 5px;
  border-radius: 999px;
  background: #10151b;
}

:root[data-theme="light"] .usage-bar {
  background: #e8eef6;
}

.usage-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--blue));
}

dialog {
  width: min(820px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0;
  background: var(--panel);
  color: var(--text);
}

dialog::backdrop {
  background: rgba(0, 0, 0, .62);
}

.dialog-panel {
  display: grid;
  gap: 18px;
  padding: 20px;
}

#usage-chart {
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0f131a;
}

:root[data-theme="light"] #usage-chart {
  background: #f7f9fc;
}

.usage-nodes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.usage-node {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: var(--panel-2);
}

@media (max-width: 980px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .filters-bar {
    width: 100%;
  }

  .filters-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .content-shell {
    padding: 16px;
    gap: 20px;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .metric {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr);
    align-items: start;
    gap: 9px;
    min-height: 108px;
    padding: 12px;
  }

  .metric strong {
    display: block;
    margin-top: 5px;
    font-size: 21px;
    line-height: 1.1;
    overflow-wrap: anywhere;
    word-break: normal;
  }

  .metric span:not(.metric-icon) {
    display: block;
    font-size: 12px;
    line-height: 1.25;
  }

  .metric-icon {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    font-size: 10px;
  }

  .brand-lockup {
    align-items: flex-start;
  }

  .topbar-brand img {
    width: 48px;
    height: 48px;
  }

  .brand-lockup img {
    width: 52px;
    height: 52px;
  }

  .filters-bar {
    grid-template-columns: 1fr;
  }

  .table-meta {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 380px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .metric {
    min-height: 92px;
  }
}
