* {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  --bg-canvas: #0f141d;
  --bg-shell: #131a24;
  --bg-panel: rgba(25, 33, 46, 0.76);
  --bg-panel-strong: rgba(19, 26, 37, 0.88);
  --bg-elevated: rgba(34, 44, 60, 0.82);
  --bg-input: rgba(15, 21, 31, 0.68);
  --line-soft: rgba(255, 255, 255, 0.08);
  --line-mid: rgba(255, 255, 255, 0.14);
  --line-strong: rgba(255, 255, 255, 0.2);
  --text-primary: #f4f8ff;
  --text-secondary: #b8c6dd;
  --text-tertiary: #8ea1bf;
  --accent: #76b9ff;
  --accent-strong: #3d8cff;
  --accent-muted: rgba(118, 185, 255, 0.18);
  --success-bg: rgba(93, 214, 156, 0.16);
  --success-fg: #8af0bf;
  --danger-bg: rgba(255, 110, 110, 0.14);
  --danger-fg: #ffb1b1;
  --shadow-soft: 0 18px 46px rgba(0, 0, 0, 0.28);
  --shadow-float: 0 24px 64px rgba(0, 0, 0, 0.34);
  --radius-panel: 8px;
  --radius-control: 8px;
}

html {
  min-height: 100%;
  background:
    linear-gradient(180deg, rgba(42, 55, 78, 0.26), transparent 32%),
    linear-gradient(135deg, #0f141d 0%, #101722 52%, #121d2a 100%);
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: var(--text-primary);
  background: transparent;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.024) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.44), transparent 82%);
  opacity: 0.36;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 18%),
    linear-gradient(90deg, rgba(118, 185, 255, 0.08), transparent 44%);
  opacity: 0.42;
}

a {
  color: inherit;
}

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

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.text-link:focus-visible {
  outline: 2px solid rgba(118, 185, 255, 0.88);
  outline-offset: 2px;
}

.app-shell {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0 56px;
  position: relative;
  z-index: 1;
}

.narrow-shell {
  width: min(1040px, calc(100% - 32px));
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 20px;
  padding: 8px 0 20px;
  margin-bottom: 8px;
}

.hero h1,
.panel h1,
.panel h2,
.panel h3 {
  margin: 0;
  letter-spacing: 0;
}

.hero h1 {
  font-size: clamp(36px, 5vw, 56px);
  font-weight: 700;
}

.hero p {
  max-width: 680px;
  margin: 12px 0 0;
  line-height: 1.6;
}

.panel {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 38%),
    var(--bg-panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-panel);
  padding: 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px) saturate(128%);
  -webkit-backdrop-filter: blur(18px) saturate(128%);
  overflow: hidden;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent 24%, transparent 74%, rgba(118, 185, 255, 0.06));
}

.panel > * {
  position: relative;
  z-index: 1;
}

.login-panel,
.auth-panel {
  margin-top: 9vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 34%),
    var(--bg-panel-strong);
  border-color: var(--line-mid);
  box-shadow: var(--shadow-float);
}

.login-panel {
  max-width: 440px;
  margin-left: auto;
  margin-right: auto;
}

.auth-panel {
  max-width: 560px;
}

.toolbar,
.stats-grid,
.grid,
.cards,
.kv-grid,
.actions,
.segmented {
  display: grid;
  gap: 16px;
}

.toolbar {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

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

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

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

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

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

.actions.single-action {
  grid-template-columns: 1fr;
}

.stack {
  display: grid;
  gap: 12px;
}

.captcha-panel {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: var(--radius-panel);
  border: 1px solid var(--line-soft);
  background: rgba(12, 18, 27, 0.42);
}

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

.captcha-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 78px;
  border-radius: var(--radius-panel);
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(10, 15, 23, 0.46);
  padding: 10px;
  transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.captcha-wrapper.captcha-verified {
  border-color: rgba(93, 214, 156, 0.32);
  background: rgba(93, 214, 156, 0.08);
}

.captcha-wrapper.captcha-error {
  border-color: rgba(255, 110, 110, 0.32);
  background: rgba(255, 110, 110, 0.08);
}

.captcha-inner {
  width: 100%;
  display: flex;
  justify-content: center;
}

.turnstile-slot {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.altcha-slot {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.altcha-slot altcha-widget {
  width: 100%;
}

.captcha-result {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  font-size: 14px;
  font-weight: 600;
}

.captcha-result.show {
  display: flex;
}

.captcha-result.success {
  color: var(--success-fg);
}

.captcha-result.fail {
  color: var(--danger-fg);
}

.captcha-result-icon {
  display: inline-flex;
  width: 18px;
  justify-content: center;
}

.stack > label,
.muted,
.message,
th,
.stat span {
  color: var(--text-tertiary);
}

.message {
  min-height: 20px;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}

.text-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: var(--radius-control);
  border: 1px solid var(--line-mid);
  background: rgba(255, 255, 255, 0.05);
  text-decoration: none;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.text-link:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.stat {
  min-height: 120px;
  padding: 18px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-panel);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 42%),
    rgba(14, 20, 30, 0.72);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.stat strong {
  display: block;
  margin-top: 10px;
  font-size: clamp(26px, 3vw, 34px);
  font-weight: 650;
  color: var(--text-primary);
}

input,
select,
textarea,
button {
  width: 100%;
  min-height: 46px;
  border-radius: var(--radius-control);
  border: 1px solid var(--line-mid);
  color: var(--text-primary);
  background: var(--bg-input);
  padding: 12px 14px;
  transition:
    border-color 140ms ease,
    background 140ms ease,
    box-shadow 140ms ease,
    transform 140ms ease;
}

input::placeholder,
textarea::placeholder {
  color: rgba(184, 198, 221, 0.72);
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--line-strong);
  background: rgba(19, 26, 37, 0.84);
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(118, 185, 255, 0.72);
  background: rgba(18, 25, 36, 0.92);
  box-shadow: 0 0 0 4px rgba(118, 185, 255, 0.14);
}

textarea {
  min-height: 108px;
  resize: vertical;
  line-height: 1.55;
}

.code-area {
  min-height: 240px;
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
}

.code-area.compact {
  min-height: 176px;
}

button {
  cursor: pointer;
  font-weight: 600;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.02)),
    linear-gradient(180deg, var(--accent), var(--accent-strong));
  border-color: rgba(146, 204, 255, 0.42);
  color: #06111f;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    0 10px 24px rgba(61, 140, 255, 0.22);
}

button:hover {
  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.36),
    0 14px 28px rgba(61, 140, 255, 0.28);
}

button:active {
  transform: translateY(0);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 8px 18px rgba(61, 140, 255, 0.22);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
  transform: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 6px 14px rgba(0, 0, 0, 0.18);
}

button.secondary,
button.segment {
  color: var(--text-primary);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02)),
    rgba(26, 35, 49, 0.84);
  border-color: var(--line-mid);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 10px 24px rgba(0, 0, 0, 0.18);
}

button.secondary:hover,
button.segment:hover {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 12px 28px rgba(0, 0, 0, 0.24);
}

button.small {
  min-height: 38px;
  padding: 8px 12px;
}

.segmented {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 6px;
  border-radius: var(--radius-panel);
  margin-bottom: 18px;
  background: rgba(12, 18, 27, 0.5);
  border: 1px solid var(--line-soft);
}

.segment {
  min-height: 42px;
}

.segment.active {
  color: #06111f;
  border-color: rgba(146, 204, 255, 0.44);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.04)),
    linear-gradient(180deg, #8bc6ff, #5aa6ff);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    0 8px 18px rgba(61, 140, 255, 0.24);
}

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-panel);
  border: 1px solid var(--line-soft);
  background: rgba(13, 18, 27, 0.34);
}

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

th,
td {
  text-align: left;
  padding: 13px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  vertical-align: top;
}

th {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.02);
}

tbody tr {
  transition: background 140ms ease;
}

tbody tr:hover {
  background: rgba(118, 185, 255, 0.06);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--success-bg);
  color: var(--success-fg);
}

.badge.ok {
  background: var(--success-bg);
  color: var(--success-fg);
}

.badge.danger {
  background: var(--danger-bg);
  color: var(--danger-fg);
}

.license-card h3 {
  font-size: 24px;
  font-weight: 650;
}

.card-toolbar {
  margin-bottom: 14px;
}

.mono {
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  word-break: break-all;
}

.hidden {
  display: none;
}

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

@media (max-width: 900px) {
  .app-shell,
  .narrow-shell {
    width: min(100% - 24px, 1280px);
  }

  .hero,
  .toolbar,
  .grid.two-col,
  .kv-grid,
  .actions,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    align-items: start;
  }

  .panel {
    padding: 18px;
  }

  .login-panel,
  .auth-panel {
    margin-top: 28px;
  }
}
