:root {
  color-scheme: dark;
  --background: #121b26;
  --header: #1e3650;
  --panel: #06182a;
  --panel-alt: #172b3d;
  --input: #344250;
  --accent: #0878ff;
  --accent-light: #6fb5ff;
  --gold: #ffc55c;
  --danger: #ff7d84;
  --success: #21c77a;
  --text: #f5f8fc;
  --muted: #aab8c5;
  --border: rgba(111, 181, 255, .22);
  --shadow: 0 24px 60px rgba(0, 0, 0, .26);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  font-size: 15px;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 0, rgba(8, 120, 255, .16), transparent 32rem),
    var(--background);
  font-family: Tahoma, "Segoe UI", sans-serif;
}

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

a:hover {
  color: #9ad0ff;
}

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

h1 {
  margin-bottom: 0;
  color: var(--gold);
  font-size: clamp(1.35rem, 2.4vw, 2rem);
  font-weight: 750;
}

h2 {
  margin: .2rem 0 0;
  color: var(--text);
  font-size: 1.18rem;
  font-weight: 700;
}

code,
.ltr {
  direction: ltr;
  unicode-bidi: embed;
  text-align: left;
}

code {
  color: #9cd0ff;
  font-family: Consolas, monospace;
}

.muted,
.field small {
  color: var(--muted);
}

.eyebrow {
  display: block;
  color: var(--accent-light);
  font-family: "Segoe UI", sans-serif;
  font-size: .67rem;
  font-weight: 800;
  letter-spacing: .16em;
  direction: ltr;
  text-align: right;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 24px 18px;
  border-left: 1px solid var(--border);
  background: linear-gradient(180deg, #0a2035, #06182a 70%);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 24px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.brand:hover {
  color: var(--text);
}

.brand img,
.auth-brand img {
  object-fit: contain;
}

.brand span {
  display: grid;
  gap: 2px;
}

.brand strong {
  color: var(--gold);
  font-family: "Segoe UI", sans-serif;
  font-size: 1rem;
  direction: ltr;
}

.brand small {
  color: var(--muted);
  font-size: .75rem;
}

.sidebar nav {
  display: grid;
  gap: 7px;
  padding: 28px 0;
}

.sidebar nav a {
  padding: 12px 14px;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 9px;
  font-weight: 650;
  transition: .16s ease;
}

.sidebar nav a:hover {
  color: var(--text);
  background: rgba(8, 120, 255, .13);
  border-color: rgba(8, 120, 255, .35);
}

.sidebar-account {
  display: grid;
  gap: 5px;
  margin-top: auto;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(23, 43, 61, .62);
}

.sidebar-account span {
  color: var(--muted);
  font-size: .74rem;
}

.sidebar-account strong {
  margin-bottom: 8px;
  direction: ltr;
  text-align: right;
}

.sidebar-account a,
.link-button {
  width: max-content;
  padding: 0;
  color: var(--accent-light);
  background: transparent;
  border: 0;
  font: inherit;
  font-size: .83rem;
  cursor: pointer;
}

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

.main-column {
  min-width: 0;
}

.topbar {
  min-height: 105px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px clamp(22px, 4vw, 54px);
  border-bottom: 1px solid var(--border);
  background: rgba(30, 54, 80, .78);
  backdrop-filter: blur(12px);
}

.content {
  width: min(1440px, 100%);
  margin-inline: auto;
  padding: 34px clamp(22px, 4vw, 54px) 60px;
}

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

.stat-card {
  position: relative;
  overflow: hidden;
  min-height: 156px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: linear-gradient(145deg, rgba(23, 43, 61, .95), rgba(6, 24, 42, .94));
  box-shadow: 0 16px 34px rgba(0, 0, 0, .13);
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--accent);
}

.stat-card.success::before { background: var(--success); }
.stat-card.gold::before { background: var(--gold); }
.stat-card.danger::before { background: var(--danger); }

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

.stat-card strong {
  margin: 8px 0 4px;
  font-family: "Segoe UI", sans-serif;
  font-size: 2.4rem;
  line-height: 1;
}

.panel {
  margin-bottom: 24px;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(155deg, rgba(23, 43, 61, .96), rgba(6, 24, 42, .96));
  box-shadow: var(--shadow);
}

.narrow-panel {
  max-width: 660px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.notice,
.alert {
  margin-bottom: 22px;
  padding: 15px 18px;
  border: 1px solid var(--border);
  border-radius: 11px;
}

.notice.warning {
  color: #ffe3a8;
  background: rgba(255, 197, 92, .09);
  border-color: rgba(255, 197, 92, .35);
}

.alert-success {
  color: #9ff0c7;
  background: rgba(33, 199, 122, .11);
  border-color: rgba(33, 199, 122, .38);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 11px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}

th {
  padding: 13px 15px;
  color: var(--accent-light);
  background: #1b3a58;
  font-weight: 700;
  white-space: nowrap;
}

td {
  padding: 14px 15px;
  border-top: 1px solid rgba(111, 181, 255, .12);
  vertical-align: middle;
}

tbody tr {
  background: rgba(6, 24, 42, .28);
}

tbody tr:nth-child(even) {
  background: rgba(52, 66, 80, .2);
}

tbody tr:hover {
  background: rgba(8, 120, 255, .08);
}

td strong,
td small {
  display: block;
}

td small {
  margin-top: 4px;
  color: var(--muted);
}

.table-link {
  display: inline-block;
  padding: 6px 11px;
  border: 1px solid rgba(8, 120, 255, .48);
  border-radius: 7px;
}

.badge {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: .74rem;
}

.badge.success {
  color: #8bf0bd;
  background: rgba(33, 199, 122, .13);
  border: 1px solid rgba(33, 199, 122, .32);
}

.badge.danger {
  color: #ffb2b6;
  background: rgba(255, 125, 132, .13);
  border: 1px solid rgba(255, 125, 132, .32);
}

.badge.warning {
  color: #ffe0a4;
  background: rgba(255, 197, 92, .13);
  border: 1px solid rgba(255, 197, 92, .32);
}

.badge.neutral {
  color: #c9d5df;
  background: rgba(170, 184, 197, .12);
  border: 1px solid rgba(170, 184, 197, .26);
}

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

.field,
.form-stack {
  display: grid;
  gap: 7px;
}

.form-stack {
  gap: 10px;
}

.form-stack .btn {
  margin-top: 12px;
}

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

label {
  color: #dce6ef;
  font-size: .86rem;
  font-weight: 650;
}

input,
textarea,
select {
  width: 100%;
  min-height: 43px;
  padding: 9px 12px;
  color: var(--text);
  background: var(--input);
  border: 1px solid #52677a;
  border-radius: 8px;
  outline: none;
  font: inherit;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(8, 120, 255, .16);
}

.ltr-input {
  direction: ltr;
  text-align: left;
}

.field-error,
.validation-summary {
  color: #ffadb2;
  font-size: .78rem;
}

.validation-summary:empty,
.field-error:empty {
  display: none;
}

.validation-summary ul {
  margin: 0;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 6px;
}

.btn {
  min-height: 41px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 17px;
  border: 1px solid transparent;
  border-radius: 8px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: filter .16s ease, transform .16s ease;
}

.btn:hover {
  filter: brightness(1.12);
  transform: translateY(-1px);
}

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

.btn-success {
  color: #041d12;
  background: var(--success);
  border-color: var(--success);
}

.btn-danger {
  color: #2b090b;
  background: var(--danger);
  border-color: var(--danger);
}

.btn-outline {
  color: var(--accent-light);
  background: transparent;
  border-color: var(--accent);
}

.btn-outline-danger {
  color: #ffabb0;
  background: transparent;
  border-color: rgba(255, 125, 132, .64);
}

.btn-lg {
  min-height: 48px;
}

.search-form {
  min-width: min(480px, 100%);
  display: flex;
  gap: 8px;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 10px;
  min-height: 170px;
  color: var(--muted);
  text-align: center;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 16% 12%, rgba(8, 120, 255, .28), transparent 32rem),
    radial-gradient(circle at 82% 90%, rgba(255, 197, 92, .12), transparent 28rem),
    #121b26;
}

.auth-card {
  width: min(500px, 100%);
  padding: 34px;
  border: 1px solid rgba(111, 181, 255, .32);
  border-radius: 20px;
  background: linear-gradient(145deg, rgba(23, 43, 61, .98), rgba(6, 24, 42, .98));
  box-shadow: 0 30px 80px rgba(0, 0, 0, .38);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 17px;
  margin-bottom: 20px;
}

.auth-brand h1 {
  margin-top: 4px;
}

.auth-card > .muted {
  margin-bottom: 22px;
  line-height: 1.9;
}

.auth-footer {
  margin-top: 24px;
  padding-top: 18px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  font-size: .76rem;
  text-align: center;
}

.license-reveal {
  display: grid;
  gap: 8px;
  margin-bottom: 24px;
  padding: 22px;
  color: #062039;
  border: 1px solid #ffe09b;
  border-radius: 14px;
  background: linear-gradient(135deg, #ffc55c, #ffe295);
  box-shadow: 0 18px 42px rgba(255, 197, 92, .18);
}

.license-reveal span,
.license-reveal p {
  margin: 0;
}

.license-reveal strong {
  font-family: Consolas, monospace;
  font-size: clamp(1rem, 2.5vw, 1.55rem);
  letter-spacing: .06em;
  overflow-wrap: anywhere;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(330px, .8fr);
  gap: 22px;
  align-items: start;
}

.meta-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 22px;
}

.meta-strip > div {
  display: grid;
  gap: 6px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: rgba(6, 24, 42, .5);
}

.meta-strip span {
  color: var(--muted);
  font-size: .74rem;
}

.danger-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 28px;
  padding: 17px;
  border: 1px solid rgba(255, 125, 132, .34);
  border-radius: 11px;
  background: rgba(255, 125, 132, .06);
}

.danger-zone p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: .8rem;
}

.device-list {
  display: grid;
  gap: 13px;
}

.device-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: rgba(6, 24, 42, .48);
}

.device-card > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.device-card dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px 14px;
  margin: 15px 0;
  font-size: .78rem;
}

.device-card dt {
  color: var(--muted);
  font-weight: 400;
}

.device-card dd {
  margin: 0;
}

.device-card .btn {
  width: 100%;
  min-height: 36px;
  font-size: .78rem;
}

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

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

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    padding: 16px;
    border-left: 0;
    border-bottom: 1px solid var(--border);
  }

  .brand {
    padding-bottom: 14px;
  }

  .sidebar nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 14px 0;
  }

  .sidebar-account {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 16px;
  }

  .sidebar-account span {
    display: none;
  }

  .topbar {
    min-height: 90px;
  }

  .responsive-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .search-form {
    min-width: 0;
  }
}

@media (max-width: 580px) {
  .topbar,
  .content {
    padding-inline: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

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

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

  .panel,
  .auth-card {
    padding: 19px;
  }

  .panel-heading,
  .danger-zone {
    align-items: stretch;
    flex-direction: column;
  }

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