:root {
  color-scheme: dark;
  --bg: #111316;
  --panel: #1b1f24;
  --panel-2: #222832;
  --line: #343c47;
  --text: #f3f5f7;
  --muted: #aab3bf;
  --accent: #d24f45;
  --accent-2: #2f9e7e;
  --warn: #d7a43b;
  --danger: #d94c5a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

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

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  min-height: 38px;
  padding: 0 14px;
}

button:hover {
  border-color: var(--accent);
}

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

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

button.upgrade {
  background: var(--accent-2);
  border-color: var(--accent-2);
}

.badge.lifetime {
  color: #72ddb7;
}

.badge.warning,
.badge.expiring {
  color: #f2c85f;
  border-color: rgba(215, 164, 59, 0.55);
}

.badge.expired {
  color: #ff8796;
  border-color: rgba(217, 76, 90, 0.65);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #101215;
  color: var(--text);
  min-height: 38px;
  padding: 8px 10px;
}

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

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

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

.hidden {
  display: none !important;
}

.login {
  width: min(560px, 100%);
  margin: 18vh auto 0;
}

.login h1,
.topbar h1 {
  margin: 0 0 8px;
  font-size: 30px;
}

.login-form {
  display: grid;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
}

.token-row,
.topbar-actions,
.filters,
.form-grid,
.button-row {
  display: flex;
  gap: 10px;
}

.message {
  min-height: 20px;
  margin: 0;
  color: var(--warn);
}

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

.topbar p {
  color: var(--muted);
  margin: 0;
}

.role-info {
  margin-top: 4px !important;
}

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

.version-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.trial-license-form {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto minmax(220px, 1fr);
  gap: 12px;
  align-items: end;
  margin-bottom: 20px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.radar-admin-panel {
  display: grid;
  gap: 12px;
  margin-bottom: 20px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.radar-admin-panel h2,
.radar-admin-panel p {
  margin: 0;
}

.radar-admin-panel p {
  color: var(--muted);
  margin-top: 4px;
}

#radarEditor {
  min-height: 150px;
  font-family: Consolas, monospace;
}

.trial-license-form .message {
  align-self: center;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.stat strong {
  display: block;
  font-size: 28px;
  margin-top: 6px;
}

.stat span,
.muted {
  color: var(--muted);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(620px, 1fr) minmax(380px, 520px);
  gap: 16px;
  align-items: start;
}

.list-panel,
.detail-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.filters {
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.audit-filters {
  background: #15191e;
}

.filters input {
  flex: 1;
}

.filters select {
  max-width: 170px;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 260px);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

tr[data-key] {
  cursor: pointer;
}

tr[data-key]:hover,
tr.selected {
  background: #252c35;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  background: #29313a;
}

.badge.active {
  color: #83dfbd;
}

.badge.blocked {
  color: #ff9aa5;
}

.badge.review {
  color: #ffd27d;
  margin-left: 6px;
}

.key-button {
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: inherit;
}

.detail-panel {
  min-height: 520px;
  padding: 16px;
}

.empty {
  color: var(--muted);
  padding: 40px 12px;
  text-align: center;
}

.detail-section {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 16px;
}

.detail-section h2 {
  font-size: 17px;
  margin: 0 0 12px;
}

.form-grid {
  flex-direction: column;
}

.device,
.audit-entry,
.order-entry {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 10px;
  background: #15191e;
}

.device-head,
.entry-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

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

@media (max-width: 980px) {
  .shell {
    width: min(100% - 20px, 1500px);
  }

  .topbar,
  .topbar-actions,
  .filters,
  .token-row {
    flex-direction: column;
  }

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

  .filters select {
    max-width: none;
  }
}
