:root {
  --bg: #ffffff;
  --bg-alt: #f7f6fb;
  --surface: #ffffff;
  --border: #e9e8f0;
  --text: #14121f;
  --text-dim: #6b7280;
  --text-faint: #9ca3af;
  --primary: #6d4aff;
  --primary-dark: #5a3ce0;
  --primary-light: #efe9ff;
  --green: #16a34a;
  --green-light: #dcfce7;
  --blue: #2563eb;
  --blue-light: #dbeafe;
  --radius: 18px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(20, 18, 31, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0d17;
    --bg-alt: #171420;
    --surface: #1a1726;
    --border: #2a2636;
    --text: #f2f1f7;
    --text-dim: #a9a5b8;
    --text-faint: #7d7891;
    --primary: #8b6bff;
    --primary-dark: #7452ff;
    --primary-light: rgba(139, 107, 255, 0.18);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  }
}

:root[data-theme="dark"] {
  --bg: #0f0d17;
  --bg-alt: #171420;
  --surface: #1a1726;
  --border: #2a2636;
  --text: #f2f1f7;
  --text-dim: #a9a5b8;
  --text-faint: #7d7891;
  --primary: #8b6bff;
  --primary-dark: #7452ff;
  --primary-light: rgba(139, 107, 255, 0.18);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

main {
  flex: 1 0 auto;
}

a {
  color: inherit;
}

/* --- nav --- */

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 2.5rem;
  border-bottom: 1px solid var(--border);
}

.nav-brand,
.footer-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.brand-icon {
  font-size: 1.4rem;
}

.brand-name {
  font-size: 1.15rem;
  font-weight: 800;
}

.nav-brand .brand-icon {
  font-size: 2.1rem;
}

.nav-brand .brand-name {
  font-size: 1.7rem;
}

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

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  width: 38px;
  height: 38px;
  border-radius: 999px;
  cursor: pointer;
  line-height: 1;
  font-size: 1rem;
}

a.theme-toggle {
  text-decoration: none;
}

.logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  padding: 0 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.logout-btn:hover {
  border-color: #dc2626;
  color: #dc2626;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: #0a66c2;
  text-decoration: none;
  transition: filter 0.15s ease;
}

.icon-btn:hover {
  filter: brightness(1.1);
  border-color: #0a66c2;
}

/* --- hero --- */

.hero {
  max-width: 1200px;
  margin: 0 auto;
  padding: 5rem 2.5rem 3rem;
}

.hero-copy h1 {
  font-size: 1.9rem;
  line-height: 1.2;
  font-weight: 800;
  margin: 0;
  max-width: 40rem;
}

.highlight {
  color: var(--primary);
}

/* --- apps section --- */

.apps-section {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 2.5rem 5rem;
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
}

.app-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.app-icon-tile {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  background: var(--primary-light);
}

.app-name {
  font-size: 1.05rem;
  font-weight: 700;
}

.app-description {
  color: var(--text-dim);
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 0;
}

.app-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
}

.tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary-dark);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  color: var(--text-faint);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-pill.online { color: var(--green); }
.status-pill.offline { color: #dc2626; }
.status-pill.checking { color: #d97706; }

.app-card a.open-btn {
  display: block;
  text-align: center;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  font-size: 0.88rem;
  text-decoration: none;
}

.app-card a.open-btn:hover {
  background: var(--primary-dark);
}

.empty-state {
  color: var(--text-dim);
  font-size: 0.9rem;
}

/* --- auth cards (/login, /forbidden) --- */

.auth-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 160px);
  padding: 2rem 1.25rem;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
  text-align: center;
}

.auth-card h1 {
  font-size: 1.3rem;
  margin: 0.75rem 0 0.4rem;
}

.auth-card p {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin: 0 0 1.5rem;
}

.auth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  box-sizing: border-box;
  padding: 0.75rem 1rem;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary), #8b6bff);
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  cursor: pointer;
}

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

.auth-btn.auth-btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.auth-note {
  margin-top: 1.25rem;
  font-size: 0.78rem;
  color: var(--text-faint);
}

/* --- footer --- */

.site-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--bg-alt);
  padding: 2.5rem;
  text-align: center;
}

.footer-brand {
  justify-content: center;
  margin-bottom: 0.5rem;
}

.footer-tagline {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin: 0 0 1rem;
}

.footer-copy {
  color: var(--text-faint);
  font-size: 0.8rem;
  margin: 0;
}

.legal-page {
  max-width: 42rem;
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
  line-height: 1.7;
}

.legal-page h1 {
  margin-bottom: 0.25rem;
}

.legal-page .updated {
  color: var(--text-faint);
  font-size: 0.85rem;
  margin-top: 0;
  margin-bottom: 2rem;
}

.legal-page h2 {
  font-size: 1.1rem;
  margin-top: 2rem;
}

.legal-page p, .legal-page li {
  color: var(--text-dim);
}

.legal-page a {
  color: var(--primary);
}
