:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #eef2f6;
  --text: #17202a;
  --muted: #667085;
  --line: #d9e0e8;
  --accent: #0f766e;
  --danger: #b42318;
  --warn: #b54708;
  --ok-bg: #dcfce7;
  --ok-text: #166534;
  --bad-bg: #fee2e2;
  --bad-text: #991b1b;
  --warn-bg: #fef3c7;
  --warn-text: #92400e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 14px;
}

.shell {
  width: min(1360px, calc(100vw - 32px));
  margin: 24px auto;
}

.topbar,
.toolbar,
.metrics,
.content,
.editor {
  margin-bottom: 16px;
}

.loginView {
  min-height: calc(100vh - 48px);
  display: grid;
  place-items: center;
}

.loginView[hidden] {
  display: none;
}

.loginPanel {
  width: min(420px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.loginPanel h1 {
  margin-bottom: 6px;
}

.loginPanel label {
  margin-top: 16px;
}

.loginPanel button {
  width: 100%;
  margin-top: 8px;
}

#portalView[hidden] {
  display: none;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  font-weight: 700;
}

h2 {
  font-size: 18px;
  margin-bottom: 12px;
}

.muted,
#subtitle {
  color: var(--muted);
}

.actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.currentUser {
  color: var(--muted);
  white-space: nowrap;
}

button,
input,
select {
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}

button {
  min-height: 38px;
  padding: 0 14px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

button:disabled {
  opacity: .65;
  cursor: default;
}

button.secondary {
  background: var(--surface);
  color: var(--text);
}

button.dangerButton {
  background: var(--danger);
  color: #fff;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metrics article,
.tableWrap,
.detail,
.editor {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metrics article {
  padding: 16px;
}

.metrics span {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
}

.metrics strong {
  display: block;
  font-size: 26px;
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 12px;
}

input,
select {
  min-height: 40px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--text);
}

.content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: start;
}

.tableWrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--surface-2);
  color: #344054;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

tr[data-license-key] {
  cursor: pointer;
}

tr[data-license-key]:hover,
tr.selected {
  background: #f0fdfa;
}

.key {
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
}

.sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge.active {
  background: var(--ok-bg);
  color: var(--ok-text);
}

.badge.revoked,
.badge.expired,
.badge.disabled,
.badge.suspended {
  background: var(--bad-bg);
  color: var(--bad-text);
}

.badge.warning {
  background: var(--warn-bg);
  color: var(--warn-text);
}

.detail {
  padding: 16px;
  position: sticky;
  top: 16px;
}

.editor {
  padding: 16px;
}

.editor[hidden] {
  display: none;
}

.editorHead,
.formActions,
.modalActions,
.detailActions,
.rowActions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.formGrid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

label input,
label select {
  color: var(--text);
  font-size: 14px;
}

.formMessage {
  min-height: 20px;
  margin-top: 12px;
  color: var(--muted);
}

.formMessage.error {
  color: var(--danger);
}

.formActions {
  justify-content: flex-end;
  margin-top: 8px;
}

.detailActions {
  margin-bottom: 12px;
}

.detailActions button {
  flex: 1;
}

.rowActions {
  justify-content: flex-start;
  gap: 8px;
}

.rowActions button {
  min-height: 32px;
  padding: 0 10px;
}

.modalBackdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgb(15 23 42 / 55%);
}

.modalBackdrop[hidden] {
  display: none;
}

.modal {
  width: min(440px, 100%);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgb(15 23 42 / 28%);
}

.modal p {
  margin-top: 10px;
  color: var(--muted);
}

.modalActions {
  justify-content: flex-end;
  margin-bottom: 12px;
  margin-top: 18px;
}

.detailBlock {
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.detailBlock:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.detailLabel {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.detailValue {
  overflow-wrap: anywhere;
}

.activation {
  padding: 10px;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
}

.empty,
.error {
  color: var(--muted);
  text-align: center;
  padding: 28px 14px;
}

.error {
  color: var(--danger);
}

@media (max-width: 900px) {
  .shell {
    width: min(100vw - 20px, 720px);
    margin: 12px auto;
  }

  .metrics,
  .toolbar,
  .content {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .actions {
    width: 100%;
  }

  .actions button {
    flex: 1;
  }

  .detailActions,
  .rowActions,
  .modalActions {
    align-items: stretch;
    flex-direction: column;
  }

  .formGrid {
    grid-template-columns: 1fr;
  }

  .detail {
    position: static;
  }
}
