:root {
  --bg: #0f172a;
  --bg-2: #111827;
  --panel: rgba(255,255,255,.08);
  --panel-2: rgba(255,255,255,.12);
  --text: #f8fafc;
  --muted: #cbd5e1;
  --primary: #60a5fa;
  --accent: #34d399;
  --danger: #f87171;
  --border: rgba(255,255,255,.12);
  --shadow: 0 10px 30px rgba(0,0,0,.22);
  --radius: 18px;
  --topbar-h: 72px;
  --bottomnav-h: 78px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: Inter, system-ui, Arial, sans-serif;
  background:
    radial-gradient(circle at top, #1e293b 0%, #111827 45%, #0b1220 100%);
  color: var(--text);
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

.app-shell {
  min-height: 100vh;
  max-width: 520px;
  margin: 0 auto;
  background: linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,.01));
  position: relative;
  overflow-x: hidden;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(18px);
  background: rgba(15, 23, 42, .78);
  border-bottom: 1px solid rgba(255,255,255,.08);
  padding-top: env(safe-area-inset-top);
}

.topbar-inner {
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  width: 46px;
  height: 46px;
  object-fit: contain;
  border-radius: 14px;
  flex-shrink: 0;
}

.brand-text {
  min-width: 0;
}

.brand-text strong {
  display: block;
  font-size: 1rem;
  line-height: 1.2;
}

.subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: .8rem;
  line-height: 1.2;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.container {
  padding: 16px;
  padding-bottom: calc(var(--bottomnav-h) + 24px + env(safe-area-inset-bottom));
}

.desktop-nav {
  display: none;
}

.nav-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.nav-item,
.card,
.hero,
.form-card,
.post-card,
.stat-card,
.list-item {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.nav-item {
  padding: 14px 10px;
  text-align: center;
  color: var(--muted);
  min-height: 84px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.nav-item img {
  width: 26px;
  height: 26px;
  object-fit: contain;
  margin: 0 auto;
}

.nav-item span {
  display: block;
  font-size: .78rem;
  line-height: 1.15;
  font-weight: 600;
  text-align: center;
  word-break: break-word;
}

.nav-item.active,
.nav-item:hover {
  color: var(--text);
  border-color: rgba(255,255,255,.22);
  background: rgba(255,255,255,.12);
}

.hero {
  padding: 22px;
  display: grid;
  gap: 18px;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.card,
.form-card,
.post-card,
.stat-card {
  padding: 18px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  background: var(--primary);
  color: #fff;
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(96,165,250,.22);
  font-weight: 600;
}

.btn-sm {
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: .9rem;
}

.btn-secondary {
  background: rgba(255,255,255,.12);
  color: var(--text);
}

.btn-danger {
  background: var(--danger);
}

.badge {
  background: rgba(255,255,255,.10);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: .85rem;
  white-space: nowrap;
}

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

.alert {
  padding: 14px 16px;
  border-radius: 14px;
  margin-bottom: 16px;
}

.alert-success {
  background: rgba(52,211,153,.18);
  border: 1px solid rgba(52,211,153,.45);
}

.alert-error {
  background: rgba(248,113,113,.18);
  border: 1px solid rgba(248,113,113,.45);
}

label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
}

input,
textarea,
select {
  width: 100%;
  padding: 13px 14px;
  background: rgba(255,255,255,.08);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 14px;
  font: inherit;
}

input::placeholder,
textarea::placeholder {
  color: #d1d9e6;
}

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

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

.post-card img {
  border-radius: 14px;
  aspect-ratio: 4/3;
  object-fit: cover;
  margin-bottom: 12px;
}

.post-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: .9rem;
  flex-wrap: wrap;
}

.inline-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.table-wrap {
  overflow-x: auto;
  border-radius: 14px;
}

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

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

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

.auth-wrap {
  width: min(100%, 420px);
  margin: 24px auto;
}

.center {
  text-align: center;
}

.kpi {
  font-size: 2rem;
  font-weight: 800;
  margin: 0;
}

.install-banner {
  display: block;
  margin: 0 auto 16px;
  width: 100%;
}

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

.list-item {
  padding: 16px;
}

.small {
  font-size: .9rem;
}

/* Bottom mobile navigation */
.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 520px;
  height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  background: rgba(15, 23, 42, .88);
  backdrop-filter: blur(18px);
  border-top: 1px solid rgba(255,255,255,.08);
  z-index: 60;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 16px;
  background: rgba(255,255,255,.04);
  border: 1px solid transparent;
  min-height: 60px;
  padding: 6px 4px;
  color: var(--muted);
}

.bottom-nav-item img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.bottom-nav-item span {
  font-size: .68rem;
  line-height: 1.1;
  font-weight: 600;
  text-align: center;
}

.bottom-nav-item.active {
  background: rgba(255,255,255,.12);
  border-color: rgba(255,255,255,.16);
  color: var(--text);
}

/* Larger screens */
@media (min-width: 761px) {
  .app-shell {
    max-width: 1100px;
  }

  .container {
    padding: 20px;
    padding-bottom: 40px;
  }

  .desktop-nav {
    display: grid;
  }

  .nav-grid {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }

  .nav-item {
    min-height: 96px;
  }

  .nav-item img {
    width: 30px;
    height: 30px;
  }

  .nav-item span {
    font-size: .82rem;
  }

  .bottom-nav {
    display: none;
  }

  .hero-grid {
    grid-template-columns: 2fr 1fr;
  }

  .card-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }

  .form-row {
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }
}

@media (max-width: 520px) {
  .topbar-actions .badge {
    display: none;
  }

  .brand-text strong {
    font-size: .95rem;
  }

  .subtitle {
    font-size: .75rem;
  }

  .card,
  .form-card,
  .post-card,
  .stat-card,
  .hero {
    padding: 16px;
  }

  .container {
    padding: 14px;
  }

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

  .nav-item {
    min-height: 82px;
    padding: 12px 8px;
  }

  .nav-item img {
    width: 24px;
    height: 24px;
  }

  .nav-item span {
    font-size: .74rem;
  }

  .bottom-nav-item span {
    font-size: .64rem;
  }
}

.nav-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.nav-item,
.card,
.hero,
.form-card,
.post-card,
.stat-card,
.list-item {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.nav-item {
  padding: 18px 12px;
  text-align: center;
  color: var(--muted);
  min-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.nav-item img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  margin: 0 auto;
}

.nav-item span {
  display: block;
  font-size: .9rem;
  line-height: 1.2;
  font-weight: 700;
  text-align: center;
  word-break: break-word;
}

.nav-item.active,
.nav-item:hover {
  color: var(--text);
  border-color: rgba(255,255,255,.22);
  background: rgba(255,255,255,.12);
}

/* Bottom mobile navigation */
.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 520px;
  height: calc(90px + env(safe-area-inset-bottom));
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  background: rgba(15, 23, 42, .88);
  backdrop-filter: blur(18px);
  border-top: 1px solid rgba(255,255,255,.08);
  z-index: 60;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 16px;
  background: rgba(255,255,255,.04);
  border: 1px solid transparent;
  min-height: 70px;
  padding: 8px 4px;
  color: var(--muted);
}

.bottom-nav-item img {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

.bottom-nav-item span {
  font-size: .72rem;
  line-height: 1.1;
  font-weight: 700;
  text-align: center;
}

.bottom-nav-item.active {
  background: rgba(255,255,255,.12);
  border-color: rgba(255,255,255,.16);
  color: var(--text);
}

@media (min-width: 761px) {
  .nav-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }

  .nav-item {
    min-height: 140px;
    padding: 22px 14px;
  }

  .nav-item img {
    width: 60px;
    height: 60px;
  }

  .nav-item span {
    font-size: 1rem;
  }
}

@media (max-width: 520px) {
  .nav-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .nav-item {
    min-height: 110px;
    padding: 16px 10px;
  }

  .nav-item img {
    width: 44px;
    height: 44px;
  }

  .nav-item span {
    font-size: .85rem;
  }

  .bottom-nav-item img {
    width: 28px;
    height: 28px;
  }

  .bottom-nav-item span {
    font-size: .68rem;
  }
}