:root {
  color-scheme: light;
  --navy-950: #07192d;
  --navy-900: #0b2341;
  --navy-800: #12365d;
  --blue-600: #1769c2;
  --blue-100: #e9f3ff;
  --slate-700: #334a62;
  --slate-600: #52677c;
  --slate-400: #94a5b6;
  --slate-300: #c9d4df;
  --slate-200: #dfe7ef;
  --slate-100: #edf2f7;
  --surface: #ffffff;
  --background: #f4f7fb;
  --green-700: #19713b;
  --green-100: #e8f7ee;
  --red-700: #a62f3c;
  --red-100: #fdecef;
  --amber-800: #825b00;
  --amber-100: #fff4d6;
  --shadow: 0 10px 30px rgba(7, 25, 45, 0.07);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--background);
  color: var(--navy-950);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

a {
  color: var(--blue-600);
}

.wrap {
  width: min(1280px, calc(100% - 32px));
  margin: 24px auto 48px;
}

.portal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 20px;
  margin-bottom: 20px;
  border-radius: 14px;
  background: var(--navy-900);
  box-shadow: var(--shadow);
}

.portal-brand {
  display: grid;
  gap: 1px;
  color: #ffffff;
}

.portal-brand span {
  color: #83bfff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.portal-brand strong {
  font-size: 18px;
  letter-spacing: 0.01em;
}

nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

nav a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  color: #eaf3fc;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

nav a:hover,
nav a:focus-visible {
  border-color: rgba(255, 255, 255, 0.42);
  background: rgba(255, 255, 255, 0.09);
  outline: none;
}

nav a.is-active {
  border-color: #ffffff;
  background: #ffffff;
  color: var(--navy-900);
}

nav a.nav-signout {
  border-color: rgba(255, 172, 183, 0.45);
  color: #ffdce1;
}

.card {
  padding: 22px;
  margin-bottom: 18px;
  overflow: hidden;
  border: 1px solid var(--slate-200);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card h1,
.card h2,
.card h3,
.page-heading h1 {
  margin-top: 0;
  color: var(--navy-950);
  line-height: 1.2;
}

.card h1,
.page-heading h1 {
  margin-bottom: 6px;
  font-size: clamp(26px, 3vw, 34px);
}

.card h2 {
  margin-bottom: 14px;
  font-size: 21px;
}

.card p:first-child {
  margin-top: 0;
}

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

.page-heading p,
.muted {
  margin: 0;
  color: var(--slate-600);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat-card {
  padding: 16px 18px;
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  background: var(--surface);
}

.stat-card span {
  display: block;
  margin-bottom: 5px;
  color: var(--slate-600);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stat-card strong {
  color: var(--navy-900);
  font-size: 26px;
}

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

.field {
  min-width: 0;
}

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

label {
  display: block;
  margin-bottom: 5px;
  color: var(--slate-700);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--slate-300);
  border-radius: 8px;
  background: #ffffff;
  color: var(--navy-950);
  font: inherit;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue-600);
  outline: 3px solid rgba(23, 105, 194, 0.14);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  margin: 0;
  font-weight: 600;
}

.checkbox-row input,
input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
  margin: 0;
  accent-color: var(--blue-600);
}

button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid var(--navy-900);
  border-radius: 8px;
  background: var(--navy-900);
  color: #ffffff;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.btn:hover,
button:focus-visible,
.btn:focus-visible {
  border-color: var(--blue-600);
  background: var(--blue-600);
  outline: none;
}

.btn-secondary {
  border-color: var(--slate-300);
  background: #ffffff;
  color: var(--navy-900);
}

.btn-secondary:hover,
.btn-secondary:focus-visible {
  border-color: var(--blue-600);
  background: var(--blue-100);
  color: var(--navy-900);
}

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

.btn-danger:hover,
.btn-danger:focus-visible {
  border-color: var(--red-700);
  background: var(--red-100);
  color: var(--red-700);
}

.btn-warning {
  border-color: #dfc273;
  background: var(--amber-100);
  color: var(--amber-800);
}

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

.button-row {
  margin-top: 18px;
}

.inline-form {
  display: inline-flex;
  margin: 0;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--slate-200);
  border-radius: 10px;
}

table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  background: #ffffff;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--slate-200);
  text-align: left;
  vertical-align: middle;
}

th {
  background: var(--slate-100);
  color: var(--slate-700);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.035em;
  text-transform: uppercase;
  white-space: nowrap;
}

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

tbody tr:hover td {
  background: #f9fbfd;
}

.code,
.license-key {
  display: inline-block;
  max-width: 100%;
  padding: 6px 8px;
  overflow-wrap: anywhere;
  border-radius: 6px;
  background: var(--slate-100);
  color: var(--navy-800);
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  text-transform: capitalize;
}

.status-active {
  background: var(--green-100);
  color: var(--green-700);
}

.status-revoked,
.status-released {
  background: var(--red-100);
  color: var(--red-700);
}

.status-expired {
  background: var(--amber-100);
  color: var(--amber-800);
}

.ok,
.err {
  padding: 12px 14px;
  margin-bottom: 16px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-weight: 600;
}

.ok {
  border-color: #b9dfc7;
  background: var(--green-100);
  color: var(--green-700);
}

.err {
  border-color: #edbbc2;
  background: var(--red-100);
  color: var(--red-700);
}

.section-note {
  margin-top: -5px;
  margin-bottom: 16px;
  color: var(--slate-600);
}

.empty-state {
  padding: 24px;
  color: var(--slate-600);
  text-align: center;
}

@media (max-width: 900px) {
  .portal-header {
    align-items: flex-start;
    flex-direction: column;
  }

  nav {
    justify-content: flex-start;
  }

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

@media (max-width: 640px) {
  .wrap {
    width: min(100% - 20px, 1280px);
    margin-top: 10px;
  }

  .portal-header,
  .card {
    padding: 16px;
    border-radius: 11px;
  }

  nav {
    width: 100%;
  }

  nav a {
    flex: 1 1 calc(50% - 8px);
    justify-content: center;
  }

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

  .field-full {
    grid-column: auto;
  }
}
