* {
  box-sizing: border-box;
}

body {
  font-family: Arial, sans-serif;
  background: #f4f4f5;
  margin: 0;
  color: #111;
}

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

.sidebar {
  width: 280px;
  flex-shrink: 0;
  background: linear-gradient(180deg, #050505 0%, #0f172a 100%);
  color: white;
  padding: 24px;
}

.logo {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 36px;
}

.logo-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: white;
  color: #111;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

.logo span {
  display: block;
  color: #aaa;
  font-size: 13px;
  margin-top: 3px;
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.menu-item {
  width: 100%;
  background: transparent;
  color: #bbb;
  border: 0;
  padding: 14px 18px;
  border-radius: 14px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  text-align: left;
}

.menu-item:hover,
.menu-item.active {
  background: white;
  color: #111;
}

.main {
  flex: 1;
  padding: 40px;
  min-width: 0;
}

.topbar {
  background: white;
  border-radius: 18px;
  padding: 26px 30px;
  margin-bottom: 24px;
  border: 1px solid #e5e5e5;
}

.topbar h1 {
  margin: 0;
  font-size: 32px;
}

.topbar p {
  margin: 8px 0 0;
  color: #666;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

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

.card {
  background: white;
  border: 1px solid #e1e1e1;
  border-radius: 18px;
  padding: 26px;
  margin-bottom: 22px;
}

.card h2 {
  margin-top: 0;
  font-size: 24px;
}

.status {
  font-size: 22px;
  font-weight: bold;
  margin-bottom: 12px;
}

.muted {
  color: #666;
}

.green {
  color: #16803c;
}

button {
  background: #111827;
  color: white;
  border: 1px solid #1f2937;
  padding: 12px 18px;
  border-radius: 9px;
  cursor: pointer;
  font-weight: 600;
}

button:hover {
  opacity: 0.85;
}

input,
select {
  padding: 13px 14px;
  border: 1px solid #ccc;
  border-radius: 9px;
  width: 100%;
  font-size: 15px;
  background: white;
}

label {
  display: block;
  font-weight: 700;
  margin: 14px 0 7px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.channels-list {
  margin-top: 22px;
}

.channel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid #eee;
  font-size: 16px;
}

.autocomplete {
  position: relative;
}

.suggestions {
  display: none;
  position: absolute;
  top: 54px;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #ddd;
  border-radius: 14px;
  max-height: 360px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
}

.suggestion {
  width: 100%;
  background: white;
  color: #111;
  border: 0;
  border-bottom: 1px solid #eee;
  border-radius: 0;
  padding: 14px 16px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
}

.suggestion:hover {
  background: #f5f5f5;
  opacity: 1;
}

.suggestion span {
  color: #666;
  font-size: 14px;
}

.product-row {
  display: grid;
  grid-template-columns: 70px 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid #eee;
}

.product-image {
  width: 70px;
  height: 70px;
  background: #f3f3f3;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.product-info span {
  color: #666;
  font-size: 14px;
}

.product-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
  font-weight: 700;
}

.small-btn {
  background: #111827;
  color: white;
  text-decoration: none;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  border: 1px solid #1f2937;
}

.logs-box {
  margin-top: 16px;
  background: #111827;
  color: #22c55e;
  padding: 18px;
  border-radius: 14px;
  max-height: 500px;
  overflow: auto;
  white-space: pre-wrap;
  font-size: 13px;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  align-items: start;
  margin-bottom: 24px;
}

.settings-column {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-column h3 {
  margin: 0 0 10px;
  font-size: 20px;
}

.settings-column button {
  width: fit-content;
  margin-top: 4px;
}

.status-text {
  margin: 10px 0 0;
  font-weight: 600;
  color: #666;
}

.save-settings-btn {
  margin-top: 10px;
}

@media (max-width: 900px) {
  .app {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
  }

  .main {
    padding: 18px;
  }

  .grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .product-row {
    grid-template-columns: 56px 1fr;
  }

  .product-actions {
    grid-column: 1 / -1;
    align-items: flex-start;
  }
}

.product-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
}

.btn-small {
  padding: 8px 12px;
  border-radius: 8px;
  border: 0;
  background: #111827;
  color: white;
  font-weight: 700;
  cursor: pointer;
}

.btn-danger {
  background: #7f1d1d;
}

.product-buttons {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
}

.small-btn,
.danger-btn {
  white-space: nowrap;
}

.danger-btn {
  background: #7f1d1d;
  color: #fff;
}

.product-row {
  transition: all .2s ease;
}

.channel-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px;
  background: linear-gradient(180deg, #050505 0%, #0f172a 100%);
  border-radius: 24px;
}

.channel-header {
  background: #111827;
  border: 1px solid #1f2937;
  color: #fff;
  border-radius: 18px;
  padding: 24px;
  margin-bottom: 18px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.channel-header h1 {
  margin: 0;
}

.channel-header p,
.channel-header span,
.channel-header small {
  color: #cbd5e1;
}

.back-link {
  color: #ffffff !important;
  font-weight: 700;
  text-decoration: none;
}

.back-link:hover {
  opacity: .8;
}

.channel-actions {
  margin-bottom: 18px;
}

.telegram-post-card {
  display: block;
  background: white;
  border: 1px solid #e5e5e5;
  border-radius: 18px;
  padding: 18px;
  margin-bottom: 16px;
  cursor: pointer;
}

.telegram-post-card:hover {
  border-color: #111;
}

.post-check {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.post-check input {
  width: auto;
}

.post-text {
  white-space: pre-wrap;
  line-height: 1.45;
  margin-bottom: 14px;
}

.post-images {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.post-images img {
  width: 120px;
  height: 150px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid #eee;
}

.search-box {
  margin-bottom: 18px;
}

.search-box input {
  width: 100%;
  height: 52px;
  font-size: 16px;
  border-radius: 12px;
  border: 1px solid #1f2937;
  padding: 0 16px;
  background: #111827;
  color: #fff;
}

.search-box input::placeholder {
  color: #94a3b8;
}

.post-select-row {
  display: flex;
  gap: 18px;
  align-items: center;
  margin-bottom: 12px;
}

.post-select-row .post-check {
  margin: 0;
}

.telegram-post-card.selected-post {
  border: 2px solid #111;
  background: #fffdf5;
}

.channel-buttons {
  display: flex;
  gap: 10px;
  align-items: center;
}

.channel-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 40px;
  padding: 0 16px;
  border-radius: 10px;
  background: #111827;
  color: white;
  text-decoration: none;
  border: 1px solid #1f2937;
  font-size: 14px;
  font-weight: 700;
}

.channel-action-btn:hover {
  opacity: 0.85;
}

.channel-delete-btn {
  height: 40px;
  padding: 0 16px;
  border-radius: 10px;
  background: #7f1d1d;
  color: white;
  font-size: 14px;
}

.preview-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px;
}

.preview-content {
  background: white;
  width: min(1100px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  overflow-x: hidden;
  border-radius: 18px;
  padding: 24px;
  scrollbar-width: none;
}

.preview-content::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.preview-content::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 18px;
}

.preview-content::-webkit-scrollbar-thumb {
  background: #cfcfcf;
  border-radius: 18px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.preview-header button {
  width: 38px;
  height: 38px;
  padding: 0;
  font-size: 22px;
}

.preview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.preview-images {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.preview-images img {
  width: 110px;
  height: 145px;
  object-fit: cover;
  border-radius: 12px;
}

.preview-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
}

.preview-content pre {
  background: #f4f4f5;
  padding: 12px;
  border-radius: 12px;
  max-height: 220px;
  overflow: auto;
}

.preview-product-card h3 {
  font-size: 26px;
  margin: 0 0 18px;
}

.preview-info-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid #eee;
}

.preview-info-row span {
  color: #666;
}

.preview-text {
  background: #f7f7f7;
  padding: 14px;
  border-radius: 12px;
  line-height: 1.5;
  max-height: 260px;
  overflow: auto;
}

.toast {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 10000;
  background: #111;
  color: white;
  padding: 14px 18px;
  border-radius: 12px;
  font-weight: 700;
  box-shadow: 0 12px 35px rgba(0,0,0,.25);
}

/* ===== НОВІ ТОВАРИ ===== */

.pending-badge{
  display:none;
  min-width:22px;
  height:22px;
  padding:0 6px;
  margin-left:8px;
  border-radius:999px;
  background:#dc2626;
  color:#fff;
  font-size:12px;
  font-weight:700;
  align-items:center;
  justify-content:center;
}

.pending-product-row{
  background:#fffbeb;
  border-radius:18px;
  padding:14px 18px;
  margin-bottom:12px;
  box-shadow:0 2px 8px rgba(0,0,0,.05);
}

.error-text{
  color:#b91c1c;
  font-weight:700;
  margin-top:12px;
}

.preview-modal{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.55);
  z-index:9999;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:30px;
}

.preview-content{
  background:#fff;
  width:min(1200px,100%);
  max-height:90vh;
  overflow:auto;
  border-radius:18px;
  padding:24px;
}

.preview-header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-bottom:20px;
}

.preview-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:24px;
}

.preview-images{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
}

.preview-images img{
  width:120px;
  height:150px;
  object-fit:cover;
  border-radius:12px;
  border:1px solid #eee;
}

.preview-footer{
  display:flex;
  justify-content:flex-end;
  margin-top:20px;
}

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

  .preview-images img{
    width:90px;
    height:120px;
  }
}

.section-header{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
}

.section-header button{
  transform:translateY(-10px);
}



/* ===== ЗАВАНТАЖЕНІ ТОВАРИ — стиль як у Нових товарах ===== */

#products .product-row{
  background:#fffbeb;
  border-radius:18px;
  padding:14px 18px;
  margin-bottom:12px;
  border-bottom:0;
  box-shadow:0 2px 8px rgba(0,0,0,.05);
  display:grid;
  grid-template-columns:78px 1fr auto;
  gap:16px;
  align-items:center;
}

#products .product-row:hover{
  box-shadow:0 4px 12px rgba(0,0,0,.07);
}

#products .product-image{
  width:78px;
  height:78px;
  border-radius:14px;
  background:#f3f3f3;
  overflow:hidden;
  border:1px solid #eee1c2;
}

#products .product-info{
  gap:5px;
}

#products .product-info strong{
  font-size:18px;
  line-height:1.3;
}

#products .product-info span{
  color:#666;
  font-size:15px;
}

#products .product-actions{
  display:flex;
  flex-direction:row;
  gap:10px;
  align-items:center;
  justify-content:flex-end;
}

#products .product-buttons{
  gap:10px;
}

#products .small-btn,
#products .danger-btn,
#products .btn-small,
#products .btn-danger{
  border-radius:10px;
  padding:10px 14px;
  font-weight:700;
}

#products .small-btn,
#products .btn-small{
  background:#111827;
  color:#fff;
  border:1px solid #1f2937;
}

#products .danger-btn,
#products .btn-danger{
  background:#8f1717;
  color:#fff;
}

@media (max-width:900px){
  #products .product-row{
    grid-template-columns:64px 1fr;
  }

  #products .product-image{
    width:64px;
    height:64px;
  }

  #products .product-actions{
    grid-column:1 / -1;
    justify-content:flex-start;
    flex-wrap:wrap;
  }
}

.posts-loader {
  color: #ffffff !important;
  opacity: .75;
  padding: 14px 0;
}



/* ===== DARK PREMIUM ONLY FOR BLACK PARTS ===== */

/* Ліва чорна панель у стилі сторінки каналу */
.sidebar {
  background: linear-gradient(180deg, #050505 0%, #0f172a 100%) !important;
  border-right: 1px solid #1f2937;
}

.logo-icon {
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
}

.menu-item {
  color: #cbd5e1;
}

.menu-item:hover,
.menu-item.active {
  background: #ffffff;
  color: #111;
}

/* Чорні кнопки робимо темно-синіми, але червоні не чіпаємо */
button:not(.danger-btn):not(.btn-danger):not(.channel-delete-btn),
.small-btn:not(.danger-btn),
.btn-small:not(.btn-danger),
.channel-action-btn {
  background: #111827;
  border: 1px solid #1f2937;
  color: #ffffff;
}

button:not(.danger-btn):not(.btn-danger):not(.channel-delete-btn):hover,
.small-btn:not(.danger-btn):hover,
.btn-small:not(.btn-danger):hover,
.channel-action-btn:hover {
  background: #0f172a;
  opacity: 1;
}

/* Червоні кнопки залишаються червоними */
.danger-btn,
.btn-danger,
.channel-delete-btn,
#products .danger-btn,
#products .btn-danger {
  background: #8f1717 !important;
  color: #ffffff !important;
}

/* Темні технічні блоки */
.logs-box {
  background: #111827 !important;
  border: 1px solid #1f2937;
  color: #22c55e;
}

/* Сторінка каналу: чорний фон + видимий текст */
.channel-page {
  background: linear-gradient(180deg, #050505 0%, #0f172a 100%) !important;
  border-radius: 24px;
}

.channel-header {
  background: #111827 !important;
  border: 1px solid #1f2937 !important;
  color: #ffffff !important;
}

.channel-header h1 {
  color: #ffffff !important;
}

.channel-header p,
.channel-header span,
.channel-header small {
  color: #cbd5e1 !important;
}

.back-link {
  color: #ffffff !important;
}

.search-box input {
  background: #111827 !important;
  border: 1px solid #1f2937 !important;
  color: #ffffff !important;
}

.search-box input::placeholder {
  color: #94a3b8 !important;
}

.posts-loader {
  color: #ffffff !important;
  opacity: .75;
  padding: 14px 0;
}



/* ===== PREMIUM BUTTON HOVER EFFECTS ===== */

.menu-item,
button,
.small-btn,
.btn-small,
.channel-action-btn {
  transition: all .25s ease;
}

.menu-item:hover,
button:hover,
.small-btn:hover,
.btn-small:hover,
.channel-action-btn:hover {
  transform: none;
  box-shadow: 0 6px 16px rgba(0,0,0,.18);
}

.menu-item:active,
button:active,
.small-btn:active,
.btn-small:active,
.channel-action-btn:active {
  transform: translateY(0);
}

button:not(.danger-btn):hover,
.small-btn:not(.danger-btn):hover,
.btn-small:not(.btn-danger):hover,
.channel-action-btn:hover {
  background: #172554 !important;
  border-color: #2563eb !important;
}

.danger-btn:hover,
.btn-danger:hover,
.channel-delete-btn:hover {
  background: #b91c1c !important;
  transform: none;
  box-shadow: 0 6px 16px rgba(185,28,28,.25);
}



/* ===== CUSTOM ALERT MODAL ===== */

.custom-alert {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.68);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  padding: 24px;
}

.custom-alert.show {
  display: flex;
}

.custom-alert-box {
  width: 430px;
  max-width: 100%;
  background: linear-gradient(180deg, #050505 0%, #0f172a 100%);
  color: #ffffff;
  border: 1px solid #1f2937;
  border-radius: 22px;
  padding: 30px 28px;
  text-align: center;
  box-shadow: 0 24px 70px rgba(0,0,0,.45);
  animation: customAlertIn .18s ease-out;
}

.custom-alert-icon {
  width: 58px;
  height: 58px;
  margin: 0 auto 14px;
  border-radius: 18px;
  background: rgba(185,28,28,.14);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
}

.custom-alert-box h3 {
  margin: 0 0 10px;
  color: #ffffff;
  font-size: 24px;
}

.custom-alert-box p {
  margin: 0 0 22px;
  color: #cbd5e1;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.custom-alert-box button {
  background: #111827;
  border: 1px solid #1f2937;
  color: #ffffff;
  border-radius: 12px;
  padding: 12px 22px;
  min-width: 140px;
}

.custom-alert-box button:hover {
  background: #172554 !important;
  border-color: #2563eb !important;
  box-shadow: 0 6px 16px rgba(0,0,0,.18);
}

@keyframes customAlertIn {
  from {
    opacity: 0;
    transform: scale(.96) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}


/* ===== SORTABLE TELEGRAM CHANNELS ===== */

.channels-order-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  color: #475569;
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 700;
}

.sortable-channel {
  padding: 14px 0;
  transition: background .18s ease, opacity .18s ease, transform .18s ease;
}

.sortable-channel.dragging {
  opacity: .45;
}

.sortable-channel.drag-over {
  background: #f8fafc;
  border-radius: 14px;
  padding-left: 12px;
  padding-right: 12px;
}

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

.channel-drag-handle {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #f1f5f9;
  color: #475569;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  user-select: none;
  font-size: 18px;
  font-weight: 800;
  flex-shrink: 0;
}

.channel-drag-handle:active {
  cursor: grabbing;
}


@media (max-width: 900px) {
  .channels-order-hint {
    flex-direction: column;
    align-items: flex-start;
  }

  .channel {
    align-items: flex-start;
  }

  .channel-left {
    width: 100%;
  }

  .channel-buttons {
    flex-wrap: wrap;
    justify-content: flex-start;
  }
}
.post-more-photos {
  width: 120px;
  height: 150px;
  border-radius: 12px;
  border: 1px solid #eee;
  background: #f3f4f6;
  color: #111;

  display: flex;
  align-items: center;
  justify-content: center;

  font-size: 24px;
  font-weight: 700;
  cursor: pointer;
}

.post-more-photos:hover {
  background: #e5e7eb;
  opacity: 1;
}

.post-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.post-date {
  margin-left: auto;
  white-space: nowrap;
  color: #666;
}