:root {
  --bg: #000000;
  --surface: #080808;
  --surface-2: #0b0b0b;
  --line: #1c1c1c;
  --line-strong: #2c2c2c;
  --text: #f5f5f5;
  --muted: #a3a3a3;
  --muted-2: #737373;
  --red: #e50914;
  --red-soft: #ff4d4d;
  --danger: #f87171;
  --font: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: "Cascadia Code", "Cascadia Mono", "JetBrains Mono", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #000;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(circle at 78% -10%, rgba(229, 9, 20, 0.12), transparent 38%),
    radial-gradient(circle at 15% 0%, rgba(255, 255, 255, 0.035), transparent 32%);
}

a {
  color: inherit;
}

button,
input,
textarea {
  font-family: inherit;
}

.eyebrow {
  display: block;
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted-2);
}

/* ---------------------------------------------------------------------- */
/* Login                                                                  */
/* ---------------------------------------------------------------------- */

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

.login-card {
  width: min(430px, 100%);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #080808;
  box-shadow: 0 40px 120px -60px rgba(0, 0, 0, 1);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand img {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

.brand strong {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--red);
}

.brand div {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand div span {
  font-size: 9px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.login-card .eyebrow {
  margin-top: 28px;
}

.login-card h1 {
  margin: 7px 0 6px;
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.login-card > p {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 12.5px;
}

.login-card label {
  display: block;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 500;
  color: #c7c7c7;
}

input,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #242424;
  border-radius: 8px;
  background: #050505;
  color: #f5f5f5;
  font-size: 12.5px;
  outline: none;
  transition: border-color 0.15s;
}

input:focus,
textarea:focus {
  border-color: #5a5a5a;
}

textarea {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.7;
  resize: vertical;
}

.login-card input {
  margin-bottom: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #111;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn:hover {
  background: #171717;
}

.btn-primary {
  background: #f5f5f5;
  border-color: #f5f5f5;
  color: #050505;
}

.btn-primary:hover {
  background: #fff;
  border-color: #fff;
}

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}

.btn-ghost:hover {
  background: #111;
  border-color: var(--line-strong);
  color: #f5f5f5;
}

.btn-danger-soft {
  background: transparent;
  border-color: var(--line-strong);
  color: #d4d4d4;
}

.btn-danger-soft:hover {
  background: #150808;
  border-color: rgba(248, 113, 113, 0.4);
  color: #fca5a5;
}

.login-card .btn-primary {
  width: 100%;
}

.form-error {
  margin: 12px 0 0;
  padding: 9px 11px;
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-radius: 8px;
  background: rgba(248, 113, 113, 0.07);
  color: #fca5a5;
  font-size: 11px;
}

.login-foot {
  display: block;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted-2);
  font-size: 10px;
  line-height: 1.55;
}

/* ---------------------------------------------------------------------- */
/* Admin                                                                  */
/* ---------------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 64px;
  padding: 10px clamp(18px, 4vw, 40px);
  border-bottom: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.86);
  backdrop-filter: blur(14px);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 4px;
  color: var(--muted-2);
  font-size: 10px;
}

.live i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #d4d4d4;
}

.main {
  width: min(1320px, 100%);
  margin: 0 auto;
  padding: 28px clamp(18px, 4vw, 40px) 50px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.page-head h1 {
  margin: 0;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.page-head p {
  margin: 5px 0 0;
  color: var(--muted-2);
  font-size: 11.5px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 9px;
  margin-bottom: 16px;
}

.stat {
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
}

.stat span {
  display: block;
  font-size: 9.5px;
  color: var(--muted-2);
}

.stat b {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  margin-bottom: 16px;
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
}

.card-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
}

.card-head p {
  margin: 3px 0 0;
  color: var(--muted-2);
  font-size: 10.5px;
}

.generate-form {
  display: grid;
  grid-template-columns: 110px 150px 150px minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 16px 18px;
}

.generate-form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.generate-form label span {
  font-size: 10.5px;
  color: #c7c7c7;
}

.generate-form .wide {
  min-width: 0;
}

.generate-form .btn {
  margin-bottom: 1px;
}

.table-wrap {
  overflow: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
}

.table th {
  padding: 8px 14px;
  text-align: left;
  font-size: 9.5px;
  font-weight: 500;
  color: var(--muted-2);
  background: #080808;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.table td {
  padding: 10px 14px;
  border-bottom: 1px solid #141414;
  vertical-align: middle;
}

.table tbody tr:hover {
  background: #0b0b0b;
}

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

.table .empty {
  padding: 32px 14px;
  text-align: center;
  color: var(--muted-2);
}

.mono {
  font-family: var(--mono);
  font-size: 10.5px;
}

.key-cell {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.key-cell b {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  color: #e5e5e5;
}

.user-name {
  font-size: 11.5px;
  font-weight: 500;
  color: #e5e5e5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
  display: inline-block;
}

.key-cell small {
  color: var(--muted-2);
  font-size: 9.5px;
}

.machine-cell {
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-width: 200px;
}

.machine-cell b {
  font-weight: 500;
  color: #d4d4d4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.machine-cell small {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--muted-2);
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 500;
  white-space: nowrap;
}

.chip.active {
  color: #f5f5f5;
  border-color: #3a3a3a;
}

.chip.unused {
  color: #d4d4d4;
  border-color: #2c2c2c;
}

.chip.expired,
.chip.revoked {
  color: #fca5a5;
  border-color: rgba(248, 113, 113, 0.3);
}

.actions-col {
  text-align: right;
}

.row-actions {
  display: flex;
  justify-content: flex-end;
}

.icon-btn {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted-2);
  font-size: 16px;
  cursor: pointer;
}

.icon-btn:hover {
  color: #fca5a5;
  border-color: rgba(248, 113, 113, 0.24);
  background: #150808;
}

/* ---------------------------------------------------------------------- */
/* Modal / toast                                                          */
/* ---------------------------------------------------------------------- */

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.74);
  backdrop-filter: blur(6px);
}

.modal {
  position: relative;
  width: min(560px, 100%);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: #080808;
  box-shadow: 0 40px 120px -30px #000;
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 17px 19px 14px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 {
  margin: 4px 0 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.modal-head p {
  margin: 4px 0 0;
  color: var(--muted-2);
  font-size: 10.5px;
}

.modal-body {
  padding: 16px 19px;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 19px;
  border-top: 1px solid var(--line);
  background: #060606;
}

.toast-stack {
  position: fixed;
  top: 76px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(340px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  padding: 11px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #0a0a0a;
  box-shadow: 0 12px 32px -18px #000;
  font-size: 11.5px;
  line-height: 1.45;
  pointer-events: auto;
  animation: toast-in 0.25s ease;
}

.toast.success {
  border-color: #2e2e2e;
}

.toast.error {
  border-color: rgba(248, 113, 113, 0.35);
  color: #fca5a5;
}

.toast b {
  display: block;
  margin-bottom: 1px;
  font-weight: 600;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1080px) {
  .generate-form {
    grid-template-columns: 1fr 1fr;
  }

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

  .generate-form .btn {
    grid-column: 1 / -1;
  }
}

@media (max-width: 860px) {
  .stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .table th,
  .table td {
    padding-left: 12px;
    padding-right: 12px;
  }
}

@media (max-width: 560px) {
  .login-card {
    padding: 24px;
  }

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

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

  .generate-form .wide,
  .generate-form .btn {
    grid-column: auto;
  }

  .page-head h1 {
    font-size: 24px;
  }

  .topbar {
    flex-wrap: wrap;
  }
}
