:root {
  color-scheme: dark;
  --bg: #111217;
  --top: #181b1f;
  --sidebar: #181b1f;
  --panel: #1f2228;
  --field: #111217;
  --text: #d8d9da;
  --muted: #9aa0a6;
  --border: #343842;
  --accent: #5794f2;
  --blue: #5794f2;
  --danger: #f2495c;
  --success: #73bf69;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, Segoe UI, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
}

button,
input,
select,
textarea {
  font: inherit;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 50px;
  padding: 0 14px;
  background: var(--top);
  border-bottom: 1px solid #2a2e36;
}

.topbar h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.topbar h1::before {
  content: "";
  display: inline-block;
  width: 13px;
  height: 13px;
  margin-right: 8px;
  background: #5794f2;
  vertical-align: -1px;
}

.topbar p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.topbar-actions,
.actions,
.chips,
.card-header,
.key-row,
.tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.shell {
  width: min(1240px, calc(100vw - 32px));
  margin: 24px auto 48px;
}

.app-frame,
.page,
.settings-stack,
.settings-content {
  display: grid;
  gap: 16px;
}

.page-header,
.project-header,
.modal-header,
.result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.page-header {
  justify-content: flex-start;
}

.project-title {
  display: grid;
  align-content: start;
  gap: 6px;
}

.project-back {
  justify-self: start;
  margin-bottom: 4px;
}

h1,
h2 {
  margin: 0;
  font-weight: 500;
}

h1 {
  font-size: 26px;
}

h2 {
  font-size: 16px;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.project-card {
  display: grid;
  gap: 14px;
  min-height: 150px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
}

.project-card:hover {
  background: #181b21;
  border-color: #3a404d;
}

.card-header {
  justify-content: space-between;
}

.key-row {
  justify-content: space-between;
}

.panel,
.empty-state {
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
}

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

.form {
  display: grid;
  gap: 11px;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 34px;
  border: 1px solid #343842;
  border-radius: 0;
  padding: 7px 9px;
  color: var(--text);
  background: var(--field);
}

input:focus,
select:focus,
textarea:focus {
  outline: 1px solid var(--blue);
  outline-offset: 0;
}

input[type="file"] {
  padding: 5px;
}

input[type="file"]::file-selector-button {
  min-height: 24px;
  margin-right: 10px;
  border: 1px solid #3a404d;
  border-radius: 0;
  color: var(--text);
  background: #2b303b;
  cursor: pointer;
}

input[type="file"]::file-selector-button:hover {
  background: #353b48;
}

textarea {
  min-height: 104px;
  resize: vertical;
}

button {
  min-height: 32px;
  border: 1px solid #3a404d;
  border-radius: 0;
  padding: 6px 11px;
  color: var(--text);
  background: #2b303b;
  cursor: pointer;
}

button:hover {
  background: #353b48;
}

button.primary,
button:not(.secondary):not(.ghost):not(.nav):not(.icon):not(.active-tab) {
  color: var(--text);
  background: #2b303b;
  border-color: #3a404d;
}

button.primary:hover,
button:not(.secondary):not(.ghost):not(.nav):not(.icon):not(.active-tab):hover {
  background: #353b48;
}

button.secondary {
  color: var(--text);
  background: #252a33;
}

button.danger {
  color: #ff9aa5;
  border-color: #6f2535;
}

button.danger:hover {
  background: #3a1620;
}

button.ghost {
  color: var(--muted);
  background: transparent;
}

button.nav {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  color: var(--muted);
  background: transparent;
  border-color: transparent;
}

button.nav.active,
button.nav:hover {
  color: var(--text);
  background: #2b3038;
}

button.icon {
  position: relative;
  width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  font-size: 0;
}

button.icon::before,
button.icon::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 13px;
  height: 2px;
  background: currentColor;
  transform: translate(-50%, -50%);
}

button.icon::after {
  width: 2px;
  height: 13px;
}

button.danger-icon {
  color: #ff9aa5;
  background: transparent;
  border-color: transparent;
}

button.danger-icon:hover {
  background: #3a1620;
  border-color: #6f2535;
}

button.danger-icon::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

button.danger-icon::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

button.trash-button {
  position: relative;
  width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  color: #ff9aa5;
  background: transparent;
  border-color: transparent;
  font-size: 0;
}

button.trash-button:hover {
  background: #3a1620;
  border-color: #6f2535;
}

button.trash-button svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: square;
  stroke-linejoin: miter;
  fill: none;
}

button:disabled {
  cursor: wait;
  opacity: .65;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 2px 7px;
  color: #d8d9da;
  background: #33435f;
  border: 1px solid #45556f;
  font-size: 11px;
}

.list,
.table-list {
  display: grid;
  gap: 0;
  margin-top: 12px;
}

.item,
.result-row {
  min-height: 40px;
  padding: 9px 10px;
  background: #181b21;
  border: 1px solid #2a2e36;
  border-bottom: 0;
}

.item:last-child,
.result-row:last-child {
  border-bottom: 1px solid #2a2e36;
}

.result-row {
  display: grid;
  grid-template-columns: auto minmax(170px, 1fr) auto auto auto;
  align-items: center;
  gap: 16px;
}

.result-field {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.result-field strong,
.result-field span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-label {
  color: var(--muted);
  font-size: 11px;
}

.purchase-number-valid strong {
  color: #73bf69;
}

.purchase-number-revoked strong {
  color: #fade2a;
}

.purchase-number-error strong {
  color: #f2495c;
}

.result-row.validation-row {
  grid-template-columns: 48px minmax(130px, 1fr) 110px minmax(180px, 2fr) minmax(140px, 1fr) minmax(140px, 1fr) 120px;
  align-items: start;
  gap: 12px 16px;
}

.validation-actions { display: grid; gap: 8px; }
.issued-table-scroll { overflow-x: auto; }
.issued-table { width: 100%; border-collapse: collapse; text-align: left; }
.issued-table th, .issued-table td { padding: 12px; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.issued-table th { color: var(--muted); font-weight: normal; }
.issued-key-info strong, .issued-key-info .result-field span:last-child { white-space: normal; overflow-wrap: anywhere; }

.validation-row > :first-child {
  justify-self: start;
}

.validation-row > :nth-child(6) {
  grid-column: 2 / -1;
  grid-row: 2;
}

.validation-row > :nth-child(7) {
  grid-column: 6;
  grid-row: 1;
}

.validation-row > :nth-child(8) {
  grid-column: 7;
  grid-row: 1;
  width: auto;
  justify-self: end;
}

@media (max-width: 1100px) {
  .result-row.validation-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .validation-row > :nth-child(n) {
    grid-column: auto;
    grid-row: auto;
  }
  .validation-row > :nth-child(4),
  .validation-row > :nth-child(6) {
    grid-column: 1 / -1;
  }
  .validation-row > :first-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 520px) {
  .result-row.validation-row {
    grid-template-columns: minmax(0, 1fr);
  }
  .validation-row > :nth-child(n) {
    grid-column: 1;
    justify-self: start;
  }
}

.validation-row .result-field strong,
.validation-row .result-field span:last-child,
.validation-report .result-field span:last-child {
  white-space: normal;
  overflow-wrap: anywhere;
}

.report-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.validation-report pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-width: 100%;
}

.connection-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.product-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.connection-text {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.product-text {
  display: grid;
  gap: 4px;
}

.connect-actions {
  margin-top: 14px;
}

.muted {
  color: var(--muted);
}

.error {
  color: var(--danger);
}

.success {
  color: var(--success);
}

pre {
  overflow: auto;
  padding: 10px;
  background: #0b0d12;
  color: #d8d9da;
  border: 1px solid var(--border);
}

pre[hidden] {
  display: none !important;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgb(0 0 0 / 65%);
  z-index: 10;
}

.modal {
  width: min(520px, 100%);
  max-height: min(820px, calc(100vh - 56px));
  overflow: auto;
  background: var(--panel);
  border: 1px solid #3a404d;
  padding: 14px;
  box-shadow: 0 20px 70px rgb(0 0 0 / 50%);
}

.modal.wide {
  width: min(980px, 100%);
}

.modal-header {
  margin-bottom: 12px;
}

.modal-header h1 {
  font-size: 20px;
  line-height: 1.15;
}

.settings-stack {
  grid-template-columns: 190px minmax(0, 1fr);
  align-items: start;
  min-height: 560px;
}

.settings-content {
  min-height: 560px;
}

.tabs {
  display: grid;
  align-content: start;
  width: 100%;
  gap: 1px;
  background: #15181e;
  border: 1px solid var(--border);
}

.tabs button {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  color: var(--muted);
  background: transparent;
  border: 0;
  text-align: left;
}

.tabs button:hover {
  color: var(--text);
  background: #22262e;
}

.tabs button.active-tab {
  color: var(--text);
  background: #2b3038;
  border-left: 3px solid var(--blue);
}

@media (max-width: 820px) {
  .project-card {
    grid-template-columns: 1fr;
  }

  .settings-stack {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .settings-content {
    min-height: 0;
  }

  .result-row {
    grid-template-columns: 1fr;
    align-items: start;
  }
}
