:root {
  --tb-shell-max-width: 1536px;
  --tb-shell-text: #111827;
  --tb-shell-muted: #6b7280;
  --tb-shell-border: #e5e7eb;
  --tb-shell-bg: #f8fafc;
  --tb-shell-card: #ffffff;
}

html {
  background: var(--tb-shell-bg);
}

body {
  margin: 0;
  color: var(--tb-shell-text);
  background: linear-gradient(180deg, #f8fafc 0%, #eef4ff 220px, #f8fafc 100%);
  min-width: 0 !important;
  padding-top: 0;
}

.tb-header {
  position: relative;
  z-index: 1000;
  height: 3.5rem;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1rem;
  background-color: #5b5bd6;
  color: #ffffff;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

#site-header-container {
  height: 3.5rem;
}

.tb-logo-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1rem;
  font-weight: 700;
  color: #ffffff;
}

.tb-logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 0.75rem;
  background-color: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.tb-nav-desktop {
  display: flex;
  align-items: center;
  gap: 1.1rem;
}

.tb-nav-link {
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
}

.tb-nav-link:hover {
  color: #ffffff;
}

.app-shell {
  box-sizing: border-box;
  display: flex;
  align-items: flex-start;
  gap: 24px;
  max-width: var(--tb-shell-max-width);
  margin: 1rem auto 0;
  padding-left: 1rem;
  padding-right: 1rem;
}

.sidebar {
  position: sticky;
  inset: auto;
  top: 1rem;
  z-index: 5;
  flex: 0 0 248px;
  width: 248px;
  height: calc(100vh - 2rem);
  max-height: calc(100vh - 2rem);
  overflow: auto;
  border-radius: 24px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.14);
}

.main {
  margin-left: 0;
  width: auto;
  min-width: 0;
  flex: 1 1 auto;
  padding: 0 0 50px;
}

.topbar {
  height: auto;
  min-height: 106px;
  padding: 10px 0 22px;
}

.toolbar,
.top-actions,
.hero-actions,
.template-center-actions,
.bulk-actions,
.warehouse-head-actions {
  flex-wrap: wrap;
}

.toolbar-left {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  min-width: 0;
}

.search {
  min-width: 0;
  width: min(100%, 380px);
}

.hero-card,
.stats-grid,
.dashboard-grid,
.invoice-layout,
.invoice-main,
.template-list,
.template-picker,
.form-grid,
.item-body,
.item-details,
.warehouse-manager-body,
.field-catalog-body,
.template-editor-body {
  min-width: 0;
}

#shared-top-ad-root,
.shared-top-ad {
  position: relative;
  z-index: 20;
}

.page-top-ad {
  width: 100%;
  border-top: 1px solid #fed7aa;
  border-bottom: 1px solid #fed7aa;
  background: #fff7ed;
}

.page-top-ad__inner {
  max-width: var(--tb-shell-max-width);
  margin: 0 auto;
  padding: 8px 12px;
  color: #c2410c;
}

.page-top-ad__inner--image {
  max-width: none;
  padding-left: 0;
  padding-right: 0;
}

.page-top-ad__image-link {
  display: block;
  width: 100%;
  overflow: hidden;
  text-decoration: none;
}

.page-top-ad__image {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  background: #ffffff;
}

.page-top-ad__link {
  display: flex;
  min-height: 40px;
  width: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: inherit;
  text-align: center;
  text-decoration: none;
}

.page-top-ad__text,
.page-top-ad__plain {
  font-size: 12px;
  font-weight: 600;
  white-space: normal;
  word-break: break-word;
}

.page-top-ad__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #ffedd5;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  color: #c2410c;
}

.page-top-ad__plain {
  display: flex;
  min-height: 40px;
  width: 100%;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.site-footer {
  max-width: var(--tb-shell-max-width);
  margin: 1.5rem auto 0;
  padding: 1.5rem 1rem 2rem;
  color: #6b7280;
  font-size: 0.95rem;
  text-align: center;
}

.site-footer a {
  color: #2563eb;
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

@media (max-width: 960px) {
  .tb-header {
    padding-left: 0.9rem;
    padding-right: 0.9rem;
  }

  .tb-nav-desktop {
    gap: 0.8rem;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .app-shell {
    flex-direction: column;
  }

  .sidebar {
    position: relative;
    top: 0;
    width: 100%;
    max-height: none;
    height: auto;
    border-radius: 18px;
  }

  .main {
    width: 100%;
  }
}

@media (max-width: 720px) {
  .tb-header {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .tb-nav-desktop {
    justify-content: flex-end;
    overflow-x: auto;
  }

  .tb-logo-area {
    min-width: 0;
  }

  .tb-logo-area span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .app-shell {
    margin-top: 0.85rem;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .topbar,
  .toolbar {
    align-items: flex-start;
  }

  .search {
    width: 100%;
  }
}

@media (min-width: 768px) {
  .tb-header {
    padding: 0 2.5rem;
  }

  .page-top-ad__inner {
    padding: 8px 16px;
  }

  .page-top-ad__link {
    min-height: 40px;
    flex-direction: row;
    gap: 8px;
  }

  .page-top-ad__text {
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}
