:root {
  --bg: #080c14;
  --surface: #111827;
  --surface-2: #182234;
  --border: #1f2937;
  --border-hi: #334155;
  --cyan: #00e5ff;
  --blue: #38bdf8;
  --emerald: #10b981;
  --amber: #f59e0b;
  --rose: #f43f5e;
  --text: #f8fafc;
  --muted: #94a3b8;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 12% 8%, rgba(0, 229, 255, 0.06), transparent 40%),
              radial-gradient(circle at 88% 92%, rgba(16, 185, 129, 0.05), transparent 40%),
              var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
  line-height: 1.55;
}

/* Android TV D-Pad & Keyboard Accessibility Focus */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
.tv-focus:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 3px;
  box-shadow: 0 0 0 6px rgba(0, 229, 255, 0.25);
  border-radius: 10px;
}

.topbar {
  background: rgba(17, 24, 39, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 800;
  font-size: 1.1rem;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--cyan), var(--emerald));
  color: #061018;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 900;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 4rem;
}

.hero {
  margin-bottom: 2rem;
}

.hero h1 {
  margin: 0 0 0.35rem;
  font-size: 1.75rem;
}

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

/* Cards & Grid */
.apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 1.25rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.app-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.app-card:hover,
.app-card:focus-within {
  border-color: var(--cyan);
  transform: translateY(-2px);
}

.app-card-head {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.app-icon {
  width: 58px;
  height: 58px;
  border-radius: 14px;
  object-fit: cover;
  background: var(--surface-2);
  border: 1px solid var(--border-hi);
  flex-shrink: 0;
}

.app-icon-placeholder {
  width: 58px;
  height: 58px;
  border-radius: 14px;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border: 1px solid var(--border-hi);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  flex-shrink: 0;
}

.app-meta h2,
.app-meta h3 {
  margin: 0;
  font-size: 1.15rem;
}

.pkg-name {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  color: var(--blue);
  word-break: break-all;
}

.app-desc {
  margin: 0;
  color: #cbd5e1;
  font-size: 0.9rem;
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.pill {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border-hi);
  color: #cbd5e1;
}

.pill-cyan {
  color: var(--cyan);
  border-color: rgba(0, 229, 255, 0.35);
  background: rgba(0, 229, 255, 0.1);
}

.pill-emerald {
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.12);
}

.pill-amber {
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.12);
}

.pill-rose {
  color: #fda4af;
  border-color: rgba(244, 63, 94, 0.4);
  background: rgba(244, 63, 94, 0.12);
}

.card-actions {
  margin-top: auto;
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.6rem 1.05rem;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--cyan), #0284c7);
  color: #061018;
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-emerald {
  background: linear-gradient(135deg, var(--emerald), #059669);
  color: #ffffff;
}

.btn-secondary {
  background: var(--surface-2);
  border-color: var(--border-hi);
  color: var(--text);
}

.btn-secondary:hover {
  border-color: var(--cyan);
}

.btn-danger {
  background: rgba(244, 63, 94, 0.14);
  border-color: rgba(244, 63, 94, 0.45);
  color: #fda4af;
}

.btn-danger:hover {
  background: rgba(244, 63, 94, 0.25);
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 0.8rem 1.4rem;
  font-size: 1rem;
}

/* Forms */
.form-grid {
  display: grid;
  gap: 1rem;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 720px) {
  .form-row-2 {
    grid-template-columns: 1fr;
  }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.input,
textarea.input {
  width: 100%;
  background: #090e17;
  border: 1px solid var(--border-hi);
  color: var(--text);
  border-radius: 9px;
  padding: 0.65rem 0.85rem;
  font-size: 0.95rem;
  font-family: inherit;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.9rem;
  color: #cbd5e1;
  cursor: pointer;
}

.checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--cyan);
}

/* Alerts */
.alert {
  padding: 0.9rem 1.15rem;
  border-radius: 10px;
  margin-bottom: 1.25rem;
  font-size: 0.92rem;
  font-weight: 600;
}

.alert-error {
  background: rgba(244, 63, 94, 0.14);
  border: 1px solid rgba(244, 63, 94, 0.45);
  color: #fecdd3;
}

.alert-success {
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(16, 185, 129, 0.45);
  color: #a7f3d0;
}

.alert-warning {
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.45);
  color: #fde68a;
}

/* Stats bar */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 640px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
}

.stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.stat-value {
  font-size: 1.65rem;
  font-weight: 900;
  color: var(--cyan);
  margin-top: 0.2rem;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  text-align: left;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

th {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: #0d1320;
}

code,
pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.code-block {
  background: #070a10;
  border: 1px solid var(--border-hi);
  border-left: 3px solid var(--cyan);
  border-radius: 9px;
  padding: 0.85rem 1rem;
  font-size: 0.82rem;
  overflow-x: auto;
  color: #e2e8f0;
  white-space: pre-wrap;
  word-break: break-all;
}

.auth-box {
  max-width: 440px;
  margin: 3rem auto;
}

.section-title {
  margin: 0 0 1rem;
  font-size: 1.2rem;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--muted);
  border: 1px dashed var(--border-hi);
  border-radius: var(--radius);
}
