:root {
  --surface: #fbf8ff;
  --surface-subtle: #f8fafc;
  --surface-panel: #ffffff;
  --surface-container: #f4f2fd;
  --surface-strong: #eef2ff;
  --border: #e2e8f0;
  --border-strong: #c3c6d7;
  --text: #1a1b22;
  --text-muted: #64748b;
  --text-soft: #434655;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-ink: #003ea8;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --danger-dark: #991b1b;
  --suspended: #475569;
  --revoked: #7f1d1d;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
  color: var(--text);
  background: var(--surface);
  font-family: Geist, "Segoe UI", Inter, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(238, 242, 255, 0.65), rgba(251, 248, 255, 0) 18rem),
    var(--surface);
}

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

a:hover {
  color: var(--primary-dark);
}

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

h1 {
  margin-bottom: 0;
  font-size: 1.9rem;
  font-weight: 650;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: 0;
}

button,
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.25rem;
  min-width: 5.75rem;
  padding: 0.45rem 0.8rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 650;
  line-height: 1.15;
  text-align: center;
  white-space: nowrap;
  transition: background-color 140ms ease, border-color 140ms ease, transform 80ms ease;
}

button:hover,
.button-link:hover {
  background: var(--primary-dark);
  color: #fff;
}

button:active,
.button-link:active {
  transform: scale(0.985);
}

button.secondary,
.button-link.secondary {
  background: #fff;
  border-color: var(--border);
  color: var(--text-soft);
}

button.secondary:hover,
.button-link.secondary:hover {
  background: var(--surface-subtle);
  border-color: var(--border-strong);
  color: var(--text);
}

button.danger {
  background: var(--danger);
}

button.danger:hover {
  background: var(--danger-dark);
}

button:disabled {
  background: #cbd5e1;
  color: #f8fafc;
  cursor: not-allowed;
}

button:disabled:hover {
  background: #cbd5e1;
}

input,
select,
textarea {
  width: 100%;
  min-height: 2.25rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.13);
  outline: none;
}

textarea {
  resize: vertical;
}

label {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.65rem;
  color: var(--text-soft);
  font-size: 0.86rem;
  font-weight: 600;
}

.admin-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.side-nav {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  height: 100vh;
  padding: 1.1rem;
  border-right: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(16px);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.35rem 0.25rem 0.8rem;
  border-bottom: 1px solid var(--border);
}

.brand-lockup strong,
.brand-lockup span {
  display: block;
}

.brand-lockup strong {
  font-size: 1rem;
  line-height: 1.1;
}

.brand-lockup span {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.brand-mark {
  display: grid;
  width: 2.15rem;
  height: 2.15rem;
  place-items: center;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-weight: 750;
}

.side-nav nav {
  display: grid;
  gap: 0.25rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 2.35rem;
  padding: 0 0.65rem;
  border-radius: 8px;
  color: var(--text-soft);
  font-weight: 600;
}

.nav-item:hover,
.nav-item-active {
  background: var(--surface-container);
  color: var(--primary-ink);
}

.nav-footer {
  display: grid;
  gap: 0.2rem;
  margin-top: auto;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-subtle);
}

.nav-footer span {
  color: var(--text-muted);
  font-size: 0.76rem;
  text-transform: uppercase;
}

.app-frame {
  min-width: 0;
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4rem;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(251, 248, 255, 0.88);
  backdrop-filter: blur(16px);
}

.global-search {
  display: flex;
  width: min(42rem, 100%);
  gap: 0.5rem;
}

.global-search input {
  min-width: 12rem;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.top-actions form {
  margin: 0;
}

.admin-main {
  width: min(100%, 1480px);
  margin: 0 auto;
  padding: 1.5rem;
}

.page-heading,
.detail-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.eyebrow {
  margin-bottom: 0.35rem;
  color: var(--primary-ink);
  font-size: 0.75rem;
  font-weight: 750;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.subtitle,
.panel-subtitle {
  color: var(--text-muted);
}

.subtitle {
  margin: 0.25rem 0 0;
  font-size: 0.95rem;
}

.panel-subtitle {
  margin: 0.15rem 0 0;
  font-size: 0.84rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.summary-item {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-panel);
}

.summary-item span,
.summary-item small {
  display: block;
  color: var(--text-muted);
}

.summary-item span {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.summary-item strong {
  display: block;
  margin-top: 0.25rem;
  color: var(--text);
  font-size: 1.75rem;
  line-height: 1.1;
}

.summary-item small {
  margin-top: 0.4rem;
  font-size: 0.8rem;
}

.workspace-grid,
.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 1rem;
  align-items: start;
}

.content-stack,
.right-rail {
  display: grid;
  gap: 1rem;
  min-width: 0;
}

.right-rail {
  position: sticky;
  top: 5rem;
}

.panel {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-panel);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}

.table-panel .panel-header {
  align-items: center;
}

.filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.filter input,
.filter select {
  width: auto;
  min-width: 10rem;
}

.filter input {
  min-width: 17rem;
}

.status-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.75rem 1rem 0;
}

.status-tabs a {
  min-height: 2rem;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text-soft);
  font-weight: 650;
}

.status-tabs a:hover,
.status-tabs a.active {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: var(--primary-ink);
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

table th,
table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

table th {
  color: #334155;
  background: var(--surface-subtle);
  font-size: 0.76rem;
  font-weight: 750;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

table tbody tr:hover {
  background: #f8fafc;
}

table tbody tr:last-child td {
  border-bottom: 0;
}

table td {
  color: var(--text-soft);
  overflow-wrap: break-word;
  word-break: normal;
}

td[data-label="Activation code"],
td[data-label="Code"],
td[data-label="License ID"],
td[data-label="Machine hash"],
.code-output,
.mono {
  overflow-wrap: anywhere;
}

.product-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--text);
  font-weight: 650;
}

.product-icon {
  display: grid;
  width: 1.55rem;
  height: 1.55rem;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-subtle);
  color: var(--primary);
}

.actions,
.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: flex-start;
}

.actions form,
.action-row form {
  margin: 0;
}

td.actions {
  min-width: 17rem;
}

.actions button {
  min-width: 0;
  padding-inline: 0.65rem;
  font-size: 0.86rem;
}

.inline-confirm {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0 0 0.35rem;
  color: var(--text-muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.inline-confirm input {
  width: auto;
  min-height: 0;
}

.empty {
  padding: 1.25rem;
  color: var(--text-muted);
  text-align: center;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  align-items: end;
  padding: 1rem;
}

.form-stack {
  display: grid;
  grid-template-columns: 1fr;
}

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

.notice,
.error {
  margin: 1rem;
  padding: 0.75rem;
  border-radius: 8px;
}

.notice {
  display: grid;
  gap: 0.5rem;
  border: 1px solid #a5f3fc;
  background: #ecfeff;
  color: #0e7490;
}

.error {
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.admin-main > .error {
  margin: 0 0 1rem;
}

.code-output {
  font-family: "JetBrains Mono", Consolas, "Liberation Mono", monospace;
  color: #164e63;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  min-height: 1.55rem;
  padding: 0.2rem 0.5rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: #f1f5f9;
  color: #334155;
  font-size: 0.78rem;
  font-weight: 750;
  text-transform: capitalize;
}

.badge::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 999px;
  background: currentColor;
}

.badge-active,
.badge-used,
.badge-published {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}

.badge-expired,
.badge-unused,
.badge-draft {
  border-color: #fed7aa;
  background: #fff7ed;
  color: #9a3412;
}

.badge-deactivated,
.badge-revoked {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.badge-paused,
.badge-superseded {
  border-color: #cbd5e1;
  background: #f8fafc;
  color: #475569;
}

.activity-list {
  display: grid;
  gap: 0;
  padding: 0.5rem 1rem 1rem;
}

.activity-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.7rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.activity-item:last-child {
  border-bottom: 0;
}

.activity-item strong,
.activity-item span {
  display: block;
}

.activity-item strong {
  color: var(--text);
}

.activity-item span {
  color: var(--text-muted);
  font-size: 0.84rem;
}

.activity-dot {
  width: 0.62rem;
  height: 0.62rem;
  margin-top: 0.34rem;
  border-radius: 999px;
  background: var(--text-muted);
}

.activity-dot.active {
  background: var(--success);
}

.activity-dot.expired {
  background: var(--warning);
}

.activity-dot.deactivated {
  background: var(--danger);
}

.detail-status {
  padding-top: 0.35rem;
}

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

.details div {
  min-width: 0;
  padding: 1rem;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.details div:nth-child(4n) {
  border-right: 0;
}

.details div:nth-last-child(-n + 4) {
  border-bottom: 0;
}

dt {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 750;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

dd {
  margin: 0.35rem 0 0;
  color: var(--text);
}

.side-details {
  display: grid;
  gap: 0.85rem;
  margin: 0;
  padding: 1rem;
}

.confirm-delete {
  min-width: 15rem;
  margin: 0;
}

.confirm-delete input {
  width: 15rem;
  max-width: 100%;
}

.delete-form {
  padding: 0.75rem;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fff7f7;
}

.danger-zone {
  border-color: #fecaca;
}

.danger-zone .panel-header {
  border-bottom-color: #fecaca;
}

.danger-zone p {
  margin: 0;
  padding: 1rem;
}

.back {
  display: inline-flex;
  align-items: center;
  min-height: 2.25rem;
  color: var(--primary);
  font-weight: 650;
}

.back::before {
  content: "←";
  margin-right: 0.45rem;
}

.muted {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.mono {
  font-family: "JetBrains Mono", Consolas, "Liberation Mono", monospace;
  font-size: 0.86rem;
}

.nav-links {
  margin: 0.45rem 0 0;
  font-size: 0.9rem;
}

main.card {
  width: min(100% - 2rem, 1280px);
  margin: 2rem auto;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-panel);
  box-shadow: var(--shadow);
}

main.auth-card {
  max-width: 30rem;
}

body:has(main.card) {
  display: block;
  padding: 0;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

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

  .workspace-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .right-rail {
    position: static;
  }

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

  .details div:nth-child(4n) {
    border-right: 1px solid var(--border);
  }

  .details div:nth-child(2n) {
    border-right: 0;
  }

  .details div:nth-last-child(-n + 4) {
    border-bottom: 1px solid var(--border);
  }

  .details div:nth-last-child(-n + 2) {
    border-bottom: 0;
  }
}

@media (max-width: 900px) {
  .admin-shell {
    grid-template-columns: 1fr;
  }

  .side-nav {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

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

  .nav-footer {
    display: none;
  }

  .top-bar,
  .page-heading,
  .detail-hero,
  .panel-header,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .global-search,
  .top-actions,
  .filter,
  .actions,
  .action-row {
    align-items: stretch;
    flex-direction: column;
  }

  .filter input,
  .filter select,
  .filter button,
  .global-search input,
  .global-search button,
  .top-actions button,
  .top-actions .button-link,
  .actions button,
  .action-row button,
  .button-link.primary {
    width: 100%;
  }

  .admin-main {
    padding: 1rem;
  }

  .summary-grid,
  .details {
    grid-template-columns: 1fr;
  }

  .details div,
  .details div:nth-child(2n),
  .details div:nth-child(4n),
  .details div:nth-last-child(-n + 2),
  .details div:nth-last-child(-n + 4) {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .details div:last-child {
    border-bottom: 0;
  }

  td.actions {
    min-width: 0;
  }

  td.actions form {
    width: 100%;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  table {
    border-collapse: separate;
    border-spacing: 0;
  }

  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }

  table tbody tr {
    margin: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
  }

  table tbody tr:hover {
    background: #fff;
  }

  table td {
    display: grid;
    grid-template-columns: minmax(7.5rem, 34%) minmax(0, 1fr);
    gap: 0.75rem;
    align-items: start;
    padding: 0.5rem 0;
    border-bottom: 1px solid #eef2f7;
    white-space: normal;
  }

  table td.actions {
    display: flex;
    gap: 0.5rem;
  }

  table td:last-child {
    border-bottom: 0;
  }

  table td::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 750;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    white-space: nowrap;
  }

  .empty {
    display: block;
  }

  .empty::before {
    content: "";
  }
}

@media (max-width: 560px) {
  h1 {
    font-size: 1.45rem;
  }

  .side-nav nav {
    grid-template-columns: 1fr;
  }

  table td {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }
}
