:root {
  --page: #1a1a2e;
  --panel: #16213e;
  --panel-2: #0f3460;
  --line: #0f3460;
  --text: #ffffff;
  --muted: #a0a0a0;
  --muted-blue: #7f8ca3;
  --accent: #e87722;
  --accent-2: #ffb15e;
  --green: #27ae60;
  --red: #c0392b;
  --blue: #2980b9;
  --purple-bg: #2d1e4d;
  --copy: #333333;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body.admin-shell {
  min-height: 100vh;
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0;
}

a {
  color: var(--accent-2);
  text-decoration: none;
}

a:hover {
  color: #ffffff;
}

.topbar {
  min-height: 138px;
  padding: 44px 16px 28px 46px;
  border-bottom: 2px solid var(--accent);
  background: var(--panel);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.brand-block::after {
  content: "";
  display: block;
  width: 297px;
  height: 2px;
  background: var(--accent);
  margin: 9px 0 8px;
}

.brand {
  color: var(--text);
  display: block;
  font-size: 17px;
  font-weight: 500;
  line-height: 1.1;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.top-actions,
.inline-form,
.filters,
.action-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.top-actions a,
.link-button {
  border: 0;
  background: #555555;
  color: var(--text);
  min-width: 88px;
  min-height: 32px;
  padding: 7px 12px;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 700;
}

.link-button {
  cursor: pointer;
}

.app-main {
  width: calc(100% - 32px);
  margin: 26px 16px 48px;
}

.anonymous-shell .app-main {
  width: 100%;
  margin: 0;
}

.page-heading,
.section-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.heading-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.utility-row {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 10px;
}

.rotate-key-button {
  min-width: 132px;
}

h1,
h2 {
  margin: 0;
  color: var(--accent);
  font-weight: 700;
}

h1 {
  font-size: clamp(1.35rem, 2vw, 2rem);
}

h2 {
  font-size: 1.1rem;
  margin-bottom: 14px;
  text-transform: uppercase;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, 168px);
  justify-content: start;
  gap: 16px;
  margin-bottom: 26px;
}

.metric,
.panel,
.login-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.metric {
  width: 168px;
  min-height: 112px;
  padding: 18px 14px;
  text-align: center;
}

.metric span {
  color: #9aa6b8;
  display: block;
  font-size: 13px;
  text-transform: uppercase;
}

.metric strong {
  color: var(--accent);
  display: block;
  font-size: 31px;
  line-height: 1.05;
  margin: 8px 0 10px;
}

.panel {
  padding: 28px;
  margin-bottom: 26px;
}

.narrow-panel {
  width: min(620px, 100%);
  margin: 70px auto;
}

.generate-grid,
.stacked-form,
.settings-grid {
  display: grid;
  gap: 12px;
}

.generate-grid {
  --generate-control-height: 40px;
  grid-template-columns: 1fr .85fr 1.2fr 1.2fr .9fr .7fr .85fr auto auto auto;
  align-items: start;
}

.generate-grid > div {
  display: grid;
  grid-template-rows: 24px var(--generate-control-height) 18px;
  min-width: 0;
}

.generate-grid > div > label:first-child,
.generate-grid > div > .field-spacer {
  align-self: start;
  line-height: 18px;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.generate-grid > div > input,
.generate-grid > div > select,
.generate-grid > div > .styled-check,
.generate-grid > div > button {
  align-self: start;
  box-sizing: border-box;
  grid-row: 2;
  height: var(--generate-control-height);
  line-height: 1.15;
  margin: 0;
  min-height: 0;
}

.generate-grid > div > input,
.generate-grid > div > select {
  padding: 0 10px;
}

.generate-grid > div > .styled-check {
  padding: 0;
}

.generate-grid > div > .styled-check input {
  height: 18px;
  margin: 0;
  min-height: 0;
  padding: 0;
  width: 18px;
}

.generate-grid > div > button {
  padding: 0 12px;
}

.generate-grid > div > .field-validation {
  grid-row: 3;
}

.settings-grid {
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  align-items: start;
}

.settings-form .panel {
  overflow: visible;
}

.settings-field {
  --settings-control-height: 40px;
  display: grid;
  grid-template-rows: 24px var(--settings-control-height) 18px;
  min-width: 0;
  position: relative;
}

.settings-field > label:first-child {
  align-self: start;
  line-height: 18px;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-field > input,
.settings-field > select,
.settings-field > .styled-check,
.settings-field > .multi-select {
  align-self: start;
  box-sizing: border-box;
  grid-row: 2;
  height: var(--settings-control-height);
  line-height: 1.15;
  margin: 0;
  min-height: 0;
}

.settings-field > input,
.settings-field > select {
  padding: 0 10px;
}

.settings-field > .styled-check {
  padding: 0;
}

.settings-field > .multi-select {
  padding: 0;
  position: relative;
}

.settings-field > .styled-check input[type="checkbox"] {
  height: 18px;
  margin: 0;
  min-height: 0;
  padding: 0;
  width: 18px;
}

.settings-field > textarea {
  grid-row: 2;
  min-height: 92px;
  resize: vertical;
}

.settings-field > .field-validation {
  grid-row: 3;
}

.settings-field.textarea-field {
  grid-template-rows: 24px minmax(92px, auto) 18px;
}

.multi-select > summary {
  align-items: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  gap: 10px;
  height: 100%;
  justify-content: space-between;
  list-style: none;
  min-width: 0;
  padding: 0 10px;
}

.multi-select > summary::-webkit-details-marker {
  display: none;
}

.multi-select > summary::after {
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--accent);
  content: "";
  flex: 0 0 auto;
  transition: transform .12s ease;
}

.multi-select[open] > summary {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(255, 157, 46, .18);
}

.multi-select[open] > summary::after {
  transform: rotate(180deg);
}

.multi-select [data-multi-select-summary] {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.multi-select-menu {
  background: #09182e;
  border: 1px solid var(--accent);
  border-radius: 6px;
  box-shadow: 0 16px 34px rgba(0, 0, 0, .36);
  left: 0;
  max-height: 240px;
  overflow-y: auto;
  padding: 6px;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 55;
}

.multi-select-option {
  align-items: center;
  border-radius: 4px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  gap: 8px;
  margin: 0;
  min-height: 34px;
  padding: 7px 8px;
  white-space: nowrap;
}

.multi-select-option:hover {
  background: rgba(232, 119, 34, .16);
}

.multi-select-option input[type="checkbox"] {
  accent-color: var(--accent);
  cursor: pointer;
  flex: 0 0 auto;
  height: 16px;
  margin: 0;
  min-height: 0;
  padding: 0;
  width: 16px;
}

.multi-select-empty {
  color: var(--muted);
  font-size: .82rem;
  padding: 9px 8px;
}

.settings-field[data-tooltip-summary]::after {
  background: #09182e;
  border: 1px solid var(--accent);
  border-radius: 6px;
  box-shadow: 0 14px 30px rgba(0, 0, 0, .32);
  color: var(--text);
  content: attr(data-tooltip-summary) "\A\A" attr(data-tooltip-detail);
  font-size: .8rem;
  left: 0;
  line-height: 1.45;
  max-width: min(460px, calc(100vw - 48px));
  opacity: 0;
  padding: 12px 14px;
  pointer-events: none;
  position: absolute;
  top: calc(100% - 4px);
  transform: translateY(-4px);
  transition: opacity .12s ease, transform .12s ease;
  visibility: hidden;
  white-space: pre-line;
  width: max-content;
  z-index: 40;
}

.settings-field[data-tooltip-summary]:hover::after,
.settings-field[data-tooltip-summary]:focus-within::after {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
}

.wide-field {
  grid-column: 1 / -1;
}

.admin-create-form {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(220px, 360px) minmax(220px, 360px) max-content;
  align-items: start;
}

.admin-field {
  --admin-control-height: 40px;
  display: grid;
  grid-template-rows: 24px var(--admin-control-height) 18px;
  min-width: 0;
}

.admin-field > label:first-child,
.admin-field > .field-spacer {
  align-self: start;
  line-height: 18px;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-field > input,
.admin-field > button {
  align-self: start;
  box-sizing: border-box;
  grid-row: 2;
  height: var(--admin-control-height);
  line-height: 1.15;
  margin: 0;
  min-height: 0;
}

.admin-field > input {
  padding: 0 10px;
}

.admin-field > button {
  padding: 0 12px;
  width: auto;
}

.admin-field > .field-validation {
  grid-row: 3;
}

.admin-inline-form {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(180px, 1fr) 70px;
  min-width: 260px;
}

.admin-inline-form input,
.admin-inline-form button,
.admin-delete-form button {
  box-sizing: border-box;
  height: 34px;
  line-height: 1.15;
  margin: 0;
  min-height: 0;
}

.admin-inline-form input {
  padding: 0 9px;
}

.admin-inline-form button,
.admin-delete-form button {
  justify-self: stretch;
  padding: 0 10px;
}

.admin-delete-form {
  display: grid;
  min-width: 86px;
}

label {
  color: var(--muted);
  display: block;
  font-size: .82rem;
  margin-bottom: 6px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel-2);
  color: var(--text);
  padding: 8px 10px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(255, 157, 46, .18);
}

.check-row {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--text);
  white-space: nowrap;
}

.check-row input {
  width: 16px;
  min-height: 16px;
}

.checkbox-field,
.button-field {
  align-content: start;
}

.styled-check {
  align-items: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  display: flex;
  justify-content: center;
  margin: 0;
  min-height: 38px;
  padding: 8px 10px;
  width: 100%;
}

.styled-check input {
  accent-color: var(--accent);
  cursor: pointer;
  min-height: 18px;
  width: 18px;
}

.field-spacer {
  display: block;
  height: 18px;
}

.primary-button,
.secondary-button,
.small-button {
  align-items: center;
  border: 1px solid transparent;
  border-radius: 5px;
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  font-weight: 700;
  justify-content: center;
  min-height: 38px;
  padding: 8px 12px;
  white-space: nowrap;
}

.primary-button {
  background: var(--accent);
}

.secondary-button,
.small-button {
  background: var(--panel-2);
  border-color: var(--line);
  color: var(--text);
}

.heading-actions .secondary-button {
  min-width: 132px;
}

.primary-button.compact {
  min-width: 83px;
}

.small-button {
  font-size: .78rem;
  min-height: 30px;
  padding: 5px 8px;
}

.danger {
  background: var(--red);
  border-color: var(--red);
  color: #ffffff;
}

.restore {
  background: var(--green);
  border-color: var(--green);
}

.reset {
  background: var(--blue);
  border-color: var(--blue);
}

.extend {
  background: var(--accent);
  border-color: var(--accent);
}

.notice {
  border-radius: 8px;
  margin-bottom: 14px;
  padding: 10px 12px;
}

.notice.success {
  background: rgba(36, 166, 106, .15);
  border: 1px solid rgba(36, 166, 106, .5);
}

.notice.error,
.validation-summary,
.field-validation {
  color: #ffdce0;
}

.notice.error {
  background: rgba(217, 75, 85, .13);
  border: 1px solid rgba(217, 75, 85, .55);
}

.empty-state {
  border: 1px dashed rgba(160, 160, 160, .32);
  border-radius: 8px;
  color: #c8d0dc;
  padding: 18px;
}

.confirm-dialog {
  width: min(520px, calc(100vw - 32px));
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
}

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

.confirm-dialog-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .45);
  padding: 24px;
}

.confirm-dialog-panel h2 {
  margin-bottom: 12px;
}

.confirm-dialog-panel p {
  color: #c8d0dc;
  font-size: .95rem;
  line-height: 1.45;
  margin: 0 0 10px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 20px;
}

.field-validation {
  display: block;
  font-size: .78rem;
  min-height: 18px;
  margin-top: 3px;
}

.table-wrap {
  overflow-x: auto;
  max-width: 100%;
  min-width: 0;
}

.licence-table,
.activity-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1280px;
}

.pending-table {
  min-width: 1120px;
}

:is(.licence-table, .activity-table) th,
:is(.licence-table, .activity-table) td {
  border-bottom: 1px solid rgba(15, 52, 96, .65);
  padding: 6px 8px;
  vertical-align: middle;
  font-size: 14px;
}

:is(.licence-table, .activity-table) th {
  background: var(--panel-2);
  color: #9aa6b8;
  font-size: 12px;
  text-transform: uppercase;
  height: auto;
}

:is(.licence-table, .activity-table) td span {
  color: var(--muted);
  display: inline;
  font-size: .8rem;
}

:is(.licence-table, .activity-table) th,
:is(.licence-table, .activity-table) td
{
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

:is(.licence-table, .activity-table) th
{
  position: relative;
}

:is(.licence-table, .activity-table) td.key-cell,
:is(.licence-table, .activity-table) td.action-cell
{
  display: table-cell;
}

:is(.licence-table, .activity-table) td > span + span,
:is(.licence-table, .activity-table) td > strong + span,
:is(.licence-table, .activity-table) .key-cell > button,
:is(.licence-table, .activity-table) .action-cell > form + form
{
  margin-inline-start: .5rem;
}

:is(.licence-table, .activity-table) td > form
{
  display: inline-flex;
  flex-wrap: nowrap;
  vertical-align: middle;
  margin-bottom: 0;
}

:is(.licence-table, .activity-table) .clipped
{
  max-width: none;
}

:is(.licence-table, .activity-table).is-resizable
{
  table-layout: fixed;
  min-width: 0;
}

:is(.licence-table, .activity-table).is-resizable th
{
  padding-inline-end: 16px;
}

.column-resize-handle
{
  position: absolute;
  inset-block: 0;
  inset-inline-end: 0;
  width: 10px;
  cursor: col-resize;
  touch-action: none;
  user-select: none;
  border-inline-end: 1px solid var(--muted-blue);
}

.table-fit-button
{
  display: block;
  margin: 0 0 6px auto;
  padding: 3px 8px;
}

.section-bar > .table-fit-button
{
  margin-block: 0;
}

.column-resize-handle:hover,
.column-resize-handle:focus-visible
{
  border-inline-end: 3px solid var(--accent);
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}

body.is-resizing-columns,
body.is-resizing-columns *
{
  cursor: col-resize;
  user-select: none;
}

.mono {
  font-family: Consolas, "Courier New", monospace;
}

.accent {
  color: var(--accent);
  font-weight: 700;
}

.key-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.key-text {
  letter-spacing: .4px;
}

.copy-button {
  border: 0;
  border-radius: 4px;
  background: var(--copy);
  color: #ffffff;
  cursor: pointer;
  font-size: 11px;
  min-height: 26px;
  padding: 4px 7px;
}

.status,
.version-pill {
  border-radius: 999px;
  display: inline-block !important;
  font-size: .75rem !important;
  font-weight: 700;
  padding: 4px 8px;
  text-transform: uppercase;
}

.status.active {
  background: #1e4d1e;
  color: #6ee88f;
}

.status.unactivated {
  background: rgba(217, 169, 61, .18);
  color: #f7d27c;
}

.status.suspended,
.status.expired {
  background: #4d1e1e;
  color: #ff7f7f;
}

.status.deleted {
  background: rgba(170, 184, 201, .16);
  color: #c6d0dd;
}

.version-pill {
  background: var(--purple-bg);
  color: #e7c8ff !important;
}

.clipped {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-stack {
  display: grid;
  gap: 8px;
}

.button-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-button {
  min-height: 37px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: transparent;
  color: #9aa6b8;
  cursor: pointer;
  padding: 7px 11px;
}

.filter-button.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  font-weight: 700;
}

.event {
  font-weight: 700;
}

.event.activate,
.event.success-event {
  color: #6ee88f;
}

.event.check {
  color: #9aa6b8;
}

.event.danger-event {
  color: #ff7f7f;
}

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

.login-panel {
  width: min(440px, 100%);
  padding: 26px;
}

.login-panel h1 {
  margin-bottom: 20px;
}

.sticky-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 26px;
}

@media (max-width: 1280px) {
  .summary-grid {
    grid-template-columns: repeat(auto-fit, 168px);
  }

  .generate-grid,
  .admin-create-form {
    grid-template-columns: repeat(3, minmax(180px, 1fr));
  }
}

@media (max-width: 760px) {
  .topbar,
  .page-heading,
  .section-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .summary-grid,
  .generate-grid,
  .admin-create-form {
    grid-template-columns: 1fr;
  }

  .app-main {
    width: calc(100% - 20px);
    margin-left: 10px;
    margin-right: 10px;
  }
}
