* {
  box-sizing: border-box;
}

:root {
  --bg: #0b0f16;
  --bg-soft: #0f1420;
  --surface: #121826;
  --surface-2: #182235;
  --border: #25324a;
  --text: #e7ecf5;
  --muted: #9aa7c4;
  --accent: #5b8cff;
  --accent-2: #7bd2ff;
  --success: #2bd576;
  --danger: #ff6b6b;
  --warning: #ffcc66;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --radius: 12px;
}

html {
  min-height: 100%;
  background: radial-gradient(1200px 800px at 10% -10%, #1b2542 0%, rgba(11, 15, 22, 0) 65%), var(--bg);
  background-repeat: no-repeat;
  background-attachment: fixed;
  background-size: cover;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Inter", system-ui, -apple-system, sans-serif;
  background: transparent;
  color: var(--text);
  line-height: 1.5;
  min-height: 100%;
}

a {
  color: var(--accent);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  background: rgba(15, 20, 32, 0.85);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-weight: 600;
  letter-spacing: 0.3px;
}

.nav {
  display: flex;
  gap: 10px;
  flex: 1;
  align-items: center;
}

.nav-group {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.nav-group-title {
  color: var(--muted);
  padding: 7px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  cursor: default;
  transition: all 0.15s ease;
  user-select: none;
  display: inline-flex;
  align-items: center;
  height: 34px;
}

.nav-group.active .nav-group-title,
.nav-group:hover .nav-group-title,
.nav-group:focus-within .nav-group-title {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

.nav-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 190px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 8px;
  display: none;
  z-index: 20;
  transform: none;
  pointer-events: auto;
}

.nav-group:hover .nav-dropdown,
.nav-group:focus-within .nav-dropdown {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-dropdown .nav-item {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  border-radius: 10px;
  padding: 0 10px;
  line-height: 1;
}

.nav-cta {
  margin-left: auto;
  align-self: center;
}

.nav-item {
  color: var(--muted);
  text-decoration: none;
  padding: 7px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  height: 34px;
}

.nav-item.active,
.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

.nav-item.nav-download {
  background: linear-gradient(180deg, #5b8cff 0%, #4b74ff 100%);
  color: #ffffff;
  border-color: transparent;
}

.nav-item.nav-download:hover {
  background: linear-gradient(180deg, #6a97ff 0%, #517bff 100%);
  color: #ffffff;
}

.logout {
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--border);
  padding: 7px 12px;
  border-radius: 10px;
  background: var(--surface);
  height: 34px;
  display: inline-flex;
  align-items: center;
}

.logout-form {
  margin: 0;
  display: flex;
  align-items: center;
}

.license-status {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(148, 163, 184, 0.12);
  color: var(--muted);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.license-status:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.license-status.ok {
  background: rgba(43, 213, 118, 0.15);
  border-color: rgba(43, 213, 118, 0.5);
  color: #b8f1c1;
}

.license-status.warning {
  background: rgba(255, 204, 102, 0.15);
  border-color: rgba(255, 204, 102, 0.5);
  color: #ffe1a3;
}

.license-status.danger {
  background: rgba(255, 107, 107, 0.15);
  border-color: rgba(255, 107, 107, 0.5);
  color: #ffb5bd;
}

.license-status.muted {
  background: rgba(148, 163, 184, 0.12);
  border-color: rgba(148, 163, 184, 0.3);
  color: var(--muted);
}

.container {
  max-width: 100%;
  width: 100%;
  margin: 22px auto 80px;
  padding: 0 22px;
}

.license-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.license-row {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: flex-end;
}

.license-item {
  min-width: 160px;
}

.license-label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.license-value {
  font-weight: 600;
}

.license-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid transparent;
}

.license-badge.ok {
  background: rgba(43, 213, 118, 0.15);
  border-color: rgba(43, 213, 118, 0.5);
  color: #b8f1c1;
}

.license-badge.warning {
  background: rgba(255, 204, 102, 0.15);
  border-color: rgba(255, 204, 102, 0.5);
  color: #ffe1a3;
}

.license-badge.danger {
  background: rgba(255, 107, 107, 0.15);
  border-color: rgba(255, 107, 107, 0.5);
  color: #ffb5bd;
}

.license-badge.muted {
  background: rgba(148, 163, 184, 0.12);
  border-color: rgba(148, 163, 184, 0.3);
  color: var(--muted);
}

.license-limits {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.license-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.license-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}

.license-muted {
  color: var(--muted);
  font-size: 13px;
}

.license-note {
  color: #ffb5bd;
  font-size: 13px;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}

.modal.open {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.7);
  backdrop-filter: blur(2px);
}

.modal-content {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 12px;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px 8px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.modal-close:hover {
  background: rgba(91, 140, 255, 0.2);
}

body.modal-open {
  overflow: hidden;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  overflow-x: auto;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
}

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

.stat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}

.stat .label {
  font-size: 12px;
  color: var(--muted);
}

.stat .value {
  font-size: 18px;
  font-weight: 600;
  margin-top: 6px;
}

label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
}

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91, 140, 255, 0.25);
}

input::placeholder,
textarea::placeholder {
  color: #7483a3;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.form-grid input.small {
  max-width: 140px;
}

.form-grid input.tiny {
  max-width: 100px;
}

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

button {
  background: linear-gradient(180deg, #5b8cff 0%, #4b74ff 100%);
  color: #ffffff;
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(75, 116, 255, 0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(75, 116, 255, 0.45);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

button.button-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}

button.button-secondary:hover {
  background: #1c283d;
  color: #ffffff;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  background: var(--surface-2);
  transition: all 0.15s ease;
}

.button:hover {
  background: #1c283d;
  color: #ffffff;
}

.button.ghost {
  background: transparent;
}

.tg-link {
  color: var(--accent-2);
  text-decoration: none;
}

.tg-link:hover {
  text-decoration: underline;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  text-decoration: none;
}

.tab.active,
.tab:hover {
  background: var(--surface-2);
  color: #ffffff;
}

.inline-form {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.section {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}

.section-desc {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  border-radius: 10px;
  overflow: hidden;
}

.table th,
.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 13px;
}

.table thead th {
  background: var(--surface-2);
  font-weight: 600;
}

.table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

.table tbody tr:hover {
  background: rgba(91, 140, 255, 0.08);
}

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

.alert {
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 12px;
  border: 1px solid transparent;
}

.alert.error {
  background: rgba(255, 107, 107, 0.12);
  border-color: rgba(255, 107, 107, 0.45);
  color: #ffb5bd;
}

.alert.success {
  background: rgba(43, 213, 118, 0.12);
  border-color: rgba(43, 213, 118, 0.4);
  color: #b8f1c1;
}

.search-form {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.search-form input {
  flex: 1;
}

.search-form input.small {
  flex: 0 0 110px;
}

.search-form.metrics {
  flex-wrap: wrap;
}

.search-form.metrics input {
  min-width: 180px;
}

.search-form.metrics input.small {
  min-width: 110px;
}

.search-form.metrics input.tiny {
  flex: 0 0 160px;
  min-width: 160px;
}

input.small {
  max-width: 140px;
}

input.tiny {
  max-width: 110px;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}

.pagination-pages {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.pagination .button.active {
  background: var(--surface-2);
  color: #ffffff;
}

.pagination .button.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.pagination-ellipsis {
  color: #9aa4b2;
  padding: 0 4px;
}

.pagination-info {
  margin-top: 6px;
  font-size: 12px;
}

.dl-page-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 6px;
}

.dl-page-sub {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 22px;
}

.downloads-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin: 0 auto 20px;
  max-width: 1200px;
}

.downloads-card {
  max-width: none;
  width: 100%;
  position: relative;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.downloads-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
  border-color: rgba(91, 140, 255, 0.3);
}

.dl-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: 14px;
  flex-shrink: 0;
}

.dl-icon.ui { background: rgba(91, 140, 255, 0.15); color: #7ba8ff; }
.dl-icon.tv { background: rgba(43, 213, 118, 0.15); color: #5de89e; }
.dl-icon.steam { background: rgba(123, 210, 255, 0.15); color: #7bd2ff; }
.dl-icon.nebula { background: rgba(168, 130, 255, 0.15); color: #b89eff; }

.dl-card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
}

.dl-card-desc {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 16px;
  line-height: 1.55;
}

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

.dl-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.15s ease;
  cursor: pointer;
  border: none;
}

.dl-btn.primary {
  background: linear-gradient(180deg, #5b8cff 0%, #4b74ff 100%);
  color: #fff;
  box-shadow: 0 6px 16px rgba(75, 116, 255, 0.3);
}

.dl-btn.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(75, 116, 255, 0.45);
}

.dl-btn.secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.dl-btn.secondary:hover {
  background: #1c283d;
  color: #fff;
}

.dl-note {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.dl-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
}

.dl-badge.ready { background: rgba(43, 213, 118, 0.12); border-color: rgba(43, 213, 118, 0.35); color: #5de89e; }
.dl-badge.pending { background: rgba(255, 204, 102, 0.12); border-color: rgba(255, 204, 102, 0.35); color: #ffe1a3; }
.dl-badge.none { background: rgba(148, 163, 184, 0.1); border-color: rgba(148, 163, 184, 0.25); color: var(--muted); }

.dl-separator {
  border: none;
  border-top: 1px solid var(--border);
  margin: 6px 0 24px;
}

.dl-section-label {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 14px;
}

.dl-instructions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin: 0 auto;
  max-width: 1200px;
}

@media (max-width: 720px) {
  .dl-instructions { grid-template-columns: 1fr; }
}

.dl-instr-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  box-shadow: none;
  display: flex;
  overflow: hidden;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.dl-instr-card:hover {
  border-color: rgba(91, 140, 255, 0.25);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.dl-instr-accent {
  width: 4px;
  flex-shrink: 0;
  border-radius: 4px 0 0 4px;
}

.dl-instr-accent.ui { background: #5b8cff; }
.dl-instr-accent.tv { background: #2bd576; }
.dl-instr-accent.steam { background: #7bd2ff; }
.dl-instr-accent.nebula { background: #b89eff; }

.dl-instr-body {
  flex: 1;
  padding: 14px 16px;
}

.dl-instr-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.dl-instr-title svg {
  flex-shrink: 0;
  opacity: 0.5;
}

.dl-steps {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.dl-steps li {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.4;
  padding: 5px 0 5px 28px;
  position: relative;
  border-left: 1px solid var(--border);
  margin-left: 10px;
}

.dl-steps li:last-child {
  border-left-color: transparent;
}

.dl-steps li::before {
  content: attr(data-n);
  position: absolute;
  left: -10px;
  top: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.chart {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chart-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chart-label {
  flex: 0 0 180px;
  color: #9aa4b2;
  font-size: 12px;
}

.chart-bar {
  flex: 1;
  height: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.chart-bar__fill {
  height: 100%;
  background: var(--accent);
}

.chart-value {
  flex: 0 0 60px;
  text-align: right;
  font-size: 12px;
}

.auth-card {
  max-width: 420px;
  margin: 60px auto 0;
}

.log-uri {
  max-width: 220px;
  white-space: normal;
  word-break: break-all;
  overflow-wrap: anywhere;
}

.log-context {
  display: block;
  max-width: 320px;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}
