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

.app-body {
  min-height: 100vh;
  background: #f8fafc;
  color: #111827;
}

.app-root {
  min-height: 100vh;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  width: min(280px, 86vw);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1rem;
  background: #ffffff;
  border-left: 1px solid #e5e7eb;
  box-shadow: -8px 0 24px rgba(15, 23, 42, 0.08);
  transform: translateX(100%);
  transition: transform .2s ease;
}

.app-sidebar.is-open {
  transform: translateX(0);
}

.app-sidebar__header,
.app-brand,
.app-sidebar__user,
.app-nav__link,
.app-ghost-button,
.app-topbar,
.app-topbar__left,
.app-topbar__actions,
.app-user-button {
  display: flex;
  align-items: center;
}

.app-sidebar__header {
  justify-content: space-between;
  gap: .75rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #f1f5f9;
}

.app-brand {
  gap: .75rem;
}

.app-brand__logo {
  width: 2.5rem;
  height: 2.5rem;
  display: grid;
  place-items: center;
  border-radius: .75rem;
  background: #ff6900;
  color: #fff;
  font-weight: 800;
}

.app-brand__eyebrow {
  font-size: .72rem;
  color: #94a3b8;
}

.app-brand__title {
  margin-top: .12rem;
  font-size: 1rem;
  font-weight: 700;
  color: #111827;
}

.app-sidebar__user {
  gap: .75rem;
  margin-top: 1.25rem;
  padding: .85rem;
  border: 1px solid #e5e7eb;
  border-radius: .95rem;
  background: #f8fafc;
}

.app-sidebar__avatar,
.app-user-button__avatar {
  width: 2.75rem;
  height: 2.75rem;
  display: grid;
  place-items: center;
  border-radius: .85rem;
  background: #fff7ed;
  color: #ea580c;
  font-weight: 800;
}

.app-sidebar__welcome {
  font-size: .72rem;
  color: #64748b;
}

.app-sidebar__username {
  font-size: .92rem;
  font-weight: 700;
  color: #111827;
}

.app-nav {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: .35rem;
  margin-top: 1rem;
}

.app-nav__link {
  gap: .75rem;
  padding: .8rem .9rem;
  border-radius: .9rem;
  color: #475569;
  text-decoration: none;
  font-size: .92rem;
  font-weight: 500;
}

.app-nav__link:hover {
  background: #f8fafc;
  color: #ea580c;
}

.app-nav__link.is-active {
  background: #fff7ed;
  color: #ea580c;
}

.app-nav__icon {
  width: 2.25rem;
  height: 2.25rem;
  display: grid;
  place-items: center;
  border-radius: .75rem;
  background: #f8fafc;
}

.app-nav__link.is-active .app-nav__icon {
  background: #ffedd5;
}

.app-sidebar__footer {
  padding-top: 1rem;
  border-top: 1px solid #f1f5f9;
}

.app-ghost-button {
  justify-content: center;
  gap: .5rem;
  width: 100%;
  padding: .8rem 1rem;
  border: 1px solid #e5e7eb;
  border-radius: .9rem;
  background: #fff;
  color: #475569;
  font-size: .9rem;
  font-weight: 600;
}

.app-ghost-button:hover {
  background: #f8fafc;
}

.app-sidebar-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(15, 23, 42, 0.28);
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  justify-content: space-between;
  gap: 1rem;
  margin: 0;
  padding: 1rem .9rem;
  background: rgba(248, 250, 252, 0.94);
  border-bottom: 1px solid #e5e7eb;
}

.app-topbar__left,
.app-topbar__actions,
.app-user-button {
  gap: .75rem;
}

.app-topbar__eyebrow {
  font-size: .72rem;
  color: #94a3b8;
}

.app-topbar__title {
  margin-top: .1rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: #111827;
}

.app-user-button {
  padding: .35rem;
  border: 1px solid #e5e7eb;
  border-radius: .9rem;
  background: #fff;
}

.app-user-button__label {
  font-size: .7rem;
  color: #94a3b8;
}

.app-user-button__name {
  font-size: .84rem;
  font-weight: 700;
  color: #111827;
}

.app-topbar__logout {
  padding: .7rem .95rem;
  border: 1px solid #e5e7eb;
  border-radius: .9rem;
  background: #fff;
  color: #475569;
  font-size: .88rem;
  font-weight: 600;
}

.app-topbar__logout:hover {
  background: #f8fafc;
}

.app-main {
  flex: 1;
  width: 100%;
  padding: .75rem;
  box-sizing: border-box;
}

.app-main > * {
  width: 100%;
}

.app-main--auth {
  padding: 0;
  margin: 0;
}

.app-icon-button {
  width: 2.6rem;
  height: 2.6rem;
  display: inline-grid;
  place-items: center;
  border: 1px solid #e5e7eb;
  border-radius: .85rem;
  background: #fff;
  color: #475569;
}

.app-mobile-only {
  display: inline-grid;
}

.app-modal-overlay,
.app-loading-overlay {
  background: rgba(15, 23, 42, 0.25);
  backdrop-filter: blur(2px);
}

.app-modal-content {
  width: min(100%, 32rem);
  padding: 1.5rem;
  border-radius: 1rem;
  background: #fff;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.12);
}

.app-loading-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-radius: 1rem;
  background: #fff;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.12);
}

.app-toast {
  min-width: 260px;
  max-width: 340px;
}

.app-toast__inner {
  padding: 1rem;
  border: 1px solid #e5e7eb;
  border-radius: 1rem;
  background: #fff;
  box-shadow: 0 16px 28px rgba(15, 23, 42, 0.1);
}

.app-toast__row {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
}

.app-toast__icon {
  font-weight: 700;
}

.app-toast__text {
  flex: 1;
  font-size: .88rem;
  line-height: 1.8;
}

.app-toast__close {
  opacity: .6;
}

.app-toast--success {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}

.app-toast--error {
  border-color: #fecdd3;
  background: #fff1f2;
  color: #be123c;
}

.app-toast--warning {
  border-color: #fde68a;
  background: #fffbeb;
  color: #92400e;
}

.app-toast--info {
  border-color: #bae6fd;
  background: #f0f9ff;
  color: #075985;
}

.app-confirm {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.app-confirm__hero,
.app-confirm__actions {
  display: flex;
  align-items: center;
}

.app-confirm__hero {
  gap: .75rem;
}

.app-confirm__icon {
  width: 2.8rem;
  height: 2.8rem;
  display: grid;
  place-items: center;
  border-radius: .85rem;
  background: #fff1f2;
  color: #e11d48;
}

.app-confirm__title {
  font-size: 1rem;
  font-weight: 700;
  color: #111827;
}

.app-confirm__subtitle {
  margin-top: .2rem;
  font-size: .78rem;
  color: #64748b;
}

.app-confirm__message {
  font-size: .9rem;
  line-height: 1.9;
  color: #334155;
}

.app-confirm__actions {
  justify-content: flex-end;
  gap: .75rem;
}

.app-confirm__cancel,
.app-confirm__confirm {
  padding: .65rem 1rem;
  border-radius: .8rem;
  font-size: .86rem;
  font-weight: 600;
}

.app-confirm__cancel {
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #475569;
}

.app-confirm__confirm {
  background: #ef4444;
  color: #fff;
}

#active-products-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

[data-auth="false"] #app-sidebar,
[data-auth="false"] #topbar {
  display: none;
}

@media (max-width: 767px) {
  .card,
  .app-modal-content,
  #products-pagination,
  #active-products-pagination {
    padding-left: .75rem;
    padding-right: .75rem;
  }

  .table-xiaomi th,
  .table-xiaomi td,
  #products-table th,
  #products-table td,
  #active-products-table th,
  #active-products-table td {
    padding: .75rem;
    font-size: .78rem;
    white-space: nowrap;
  }

  #products-table .overflow-x-auto,
  #active-products-table .overflow-x-auto {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  #products-table table,
  #active-products-table table {
    min-width: 720px;
  }
}

@media (min-width: 1024px) {
  #active-products-stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .app-mobile-only {
    display: none !important;
  }

  .app-root {
    display: flex;
  }

  .app-sidebar {
    position: sticky;
    transform: none;
    width: 280px;
    height: 100vh;
  }

  .app-shell {
    min-width: 0;
    flex: 1;
  }

  .app-topbar {
    padding: 1rem 1.5rem;
  }

  .app-main {
    padding: 1.5rem;
  }

  .app-main--auth {
    padding: 0;
  }
}
