* {
  box-sizing: border-box;
  font-family: Inter, -apple-system, Arial, sans-serif;
  margin: 0;
}

body {
  background: #0f1115;
  color: #ebedf0;
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

/* ---- Auth page ---- */
.page {
  min-height: 100vh;
}

.auth-box {
  max-width: 380px;
  margin: 0 auto;
  padding: 80px 20px 40px;
  text-align: center;
}

.auth-box h1 {
  font-size: 28px;
  margin-bottom: 4px;
}

.subtitle {
  color: #888;
  margin-bottom: 32px;
  font-size: 14px;
}

.switch-link {
  margin-top: 12px;
  font-size: 13px;
  color: #888;
}

.switch-link a {
  color: #4d8ef7;
  text-decoration: none;
}

/* ---- Banner ---- */
.banner {
  max-width: 700px;
  margin: 80px auto;
  background: #1c1f27;
  border: 1px solid #3a3f4a;
  border-radius: 10px;
  padding: 32px;
  text-align: center;
}

.banner p {
  margin-bottom: 12px;
  font-size: 14px;
}

.banner .row input {
  max-width: 260px;
}

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

/* ---- App Layout ---- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  width: 240px;
  min-width: 240px;
  background: #13161c;
  border-right: 1px solid #2b2f36;
  display: flex;
  flex-direction: column;
  padding: 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 50;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid #2b2f36;
}

.sidebar-logo h2 {
  font-size: 17px;
  font-weight: 700;
  color: #ebedf0;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-group-title {
  font-size: 11px;
  color: #6f7889;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 10px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  color: #9ca3b0;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
}

.nav-link:hover {
  background: #1c2029;
  color: #d1d5dc;
}

.nav-link.active {
  background: #1e2536;
  color: #4d8ef7;
}

.nav-link svg {
  flex-shrink: 0;
}

.nav-link-label {
  flex: 1;
  min-width: 0;
}

.nav-reels-hint {
  font-size: 11px;
  color: #8b7355;
  padding: 0 10px 10px;
  line-height: 1.4;
  margin: -4px 0 0;
}

.nav-link-reels-paused {
  opacity: 0.88;
}

.nav-soon-badge {
  margin-left: auto;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 7px;
  border-radius: 4px;
  background: rgba(245, 158, 11, 0.14);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid #2b2f36;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
}

.user-info {
  font-size: 12px;
  color: #888;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.club-access-info {
  grid-column: 1 / 2;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.club-access-label {
  font-size: 11px;
  color: #6f7889;
}

#sidebarClubAccessUntil {
  font-size: 12px;
  color: #d6deea;
  font-weight: 600;
}

/* ---- Main area ---- */
.main-area {
  flex: 1;
  margin-left: 240px;
  padding: 24px 32px 48px;
  min-height: 100vh;
}

/* Same horizontal band as .analyze-card / views (1540) */
.main-content-band {
  max-width: 1540px;
  margin: 0 auto;
  width: 100%;
}

/* ---- Job status bar ---- */
.job-bar {
  background: #10141d;
  border: 1px solid #252c3d;
  border-radius: 14px;
  padding: 12px 16px;
  margin-bottom: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: #9eb8e8;
}

.main-content-band .job-bar:not(.hidden) {
  margin-bottom: 14px;
}

.media-sync-strip {
  margin-bottom: 14px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid #4a3d1a;
  background: linear-gradient(180deg, #1f1a12 0%, #16130e 100%);
  color: #e8c547;
  font-size: 13px;
  line-height: 1.45;
}

body.media-sync-active .post-meta-row .sync-pill {
  display: none;
}

.job-bar-body {
  flex: 1;
  min-width: 0;
}

.job-bar-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: stretch;
}

.job-chip {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #3d5a9e;
  background: #141a2e;
  min-width: 0;
  max-width: 100%;
}

.job-chip-running {
  border-color: #4d8ef7;
  box-shadow: 0 0 0 1px rgba(77, 142, 247, 0.25);
}

.job-chip-queued {
  opacity: 0.92;
  border-style: dashed;
}

.job-chip-user {
  font-weight: 600;
  color: #c8d9ff;
  word-break: break-all;
}

.job-chip-meta {
  font-size: 11px;
  color: #7aa3e8;
}

.job-chip-limit {
  font-size: 11px;
  color: #6b7fa8;
}

.job-bar-hint {
  margin: 8px 0 0;
  font-size: 12px;
  color: #6b8fd4;
  line-height: 1.4;
}

.job-bar .btn-sm {
  margin: 0;
  flex-shrink: 0;
}

/* ---- Views ---- */
#viewCompetitors,
#viewReelsCompetitors,
#viewCompetitorDetail,
#viewBulk,
#viewAllPosts,
#viewAllReels,
#viewFavorites,
#viewReelsFavorites,
#viewOneOff,
#viewReelsOneOff,
#viewReelsTracking,
#viewAdmin {
  max-width: 1540px;
  margin: 0 auto;
}

.view-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.view-header h1 {
  font-size: 22px;
  font-weight: 700;
}

/* ---- Unified spacing for carousel-post pages ---- */
.carousel-page {
  --carousel-gap: 14px;
  display: flex;
  flex-direction: column;
  gap: var(--carousel-gap);
  padding-top: 2px;
}

.carousel-page .view-header,
.carousel-page .analyze-card,
.carousel-page .grid,
.carousel-page .table-wrap,
.carousel-page .load-more-wrap {
  margin-top: 0;
  margin-bottom: 0;
}

.carousel-page .detail-header {
  margin-top: 0;
}

.btn-back {
  width: auto !important;
  padding: 6px 14px !important;
  font-size: 13px !important;
  background: #2b2f36;
  color: #ccc;
  border-radius: 8px;
  border: 0;
  cursor: pointer;
}

.btn-back:hover {
  background: #3a3f4a;
}

/* ---- Detail page header ---- */
.detail-header {
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid #1f2533;
}
.detail-header-info {
  flex: 1;
}
.detail-header-info h1 {
  margin-bottom: 4px;
}
.detail-stats {
  font-size: 13px;
  color: #888;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.btn-ig-link {
  display: flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #833ab4, #fd1d1d, #fcb045);
  color: #fff;
  padding: 8px 14px;
  border-radius: 8px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: opacity .15s;
}
.btn-ig-link:hover { opacity: 0.85; }
.btn-ig-link svg { flex-shrink: 0; }

/* ---- Detail actions ---- */
.detail-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.sort-label {
  font-size: 12px;
  color: #888;
}
.sort-select {
  background: #151923;
  border: 1px solid #2f3544;
  color: #d8deea;
  border-radius: 8px;
  font-size: 12px;
  padding: 8px 10px;
  min-width: 140px;
  outline: none;
}
.sort-select:focus {
  border-color: #4d8ef7;
}
.btn-ig-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid #3a3f4a;
  background: #1a1e2a;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #f16da5;
  text-decoration: none;
  transition: background .15s, border-color .15s, color .15s;
}
.btn-ig-icon:hover {
  background: #252b3c;
  border-color: #e1306c66;
  color: #ff8fbc;
}

/* ---- Scrape form ---- */
.scrape-form {
  margin-bottom: 24px;
}

.scrape-form h3 {
  margin-bottom: 12px;
  font-size: 15px;
  font-weight: 600;
}

.competitors-header {
  margin-bottom: 8px;
}

.analyze-card {
  width: 100%;
  max-width: none;
  background: #10141d;
  border: 1px solid #252c3d;
  border-radius: 14px;
  padding: 20px 22px 16px;
  margin: 0 0 18px;
}
.analyze-card h2 {
  font-size: 34px;
  margin-bottom: 8px;
  line-height: 1.1;
}
.analyze-subtitle {
  font-size: 13px;
  color: #9ba3b6;
  margin-bottom: 18px;
}
.analyze-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}
.analyze-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.analyze-input-wrap {
  position: relative;
  flex: 1;
}
.analyze-input-wrap input {
  margin-bottom: 0;
}
.analyze-limit {
  width: 92px;
  min-width: 92px;
  margin-bottom: 0;
  text-align: center;
  background: #11141b;
  border: 1px solid #2d3340;
  color: #ebedf0;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
}
.analyze-limit:focus {
  border-color: #4d8ef7;
}
.analyze-btn {
  width: auto !important;
  min-width: 170px;
  margin-bottom: 0 !important;
  background: #e76332;
  padding: 11px 20px !important;
}
.analyze-btn:hover {
  background: #d95a2c;
}
.analyze-warning {
  margin-top: 10px;
  font-size: 12px;
  color: #9ba3b6;
}
.analyze-warning span {
  color: #ff7748;
  font-weight: 700;
  margin-right: 4px;
}

.form-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.form-row.compact input {
  margin-bottom: 0;
}
.form-row.compact #competitor {
  flex: 1;
}
.form-row.compact #limit {
  width: 90px;
  min-width: 90px;
}
.form-row.compact #runJobBtn {
  width: auto;
  min-width: 110px;
  margin-bottom: 0;
}

.form-row input {
  margin-bottom: 0;
}

.form-row input[type="number"] {
  width: 120px;
  min-width: 100px;
}

.form-row button {
  width: auto;
  white-space: nowrap;
  margin-bottom: 0;
  padding: 10px 20px;
}

/* ---- Competitors grid ---- */
.competitors-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.bulk-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 320px));
  gap: 14px;
  justify-content: start;
}

.bulk-card {
  background: linear-gradient(180deg, #141a24 0%, #121722 100%);
  border: 1px solid #2a3345;
  border-radius: 12px;
  padding: 13px;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.22);
}

.bulk-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bulk-profile {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.bulk-avatar,
.bulk-avatar-fallback {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid #2f3950;
  flex-shrink: 0;
}

.bulk-avatar {
  object-fit: cover;
  background: #141a27;
}

.bulk-avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #1e2a3f;
  color: #9fc2ff;
  font-size: 12px;
  font-weight: 700;
}

.bulk-profile-meta {
  min-width: 0;
}

.bulk-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bulk-sub {
  margin-top: 2px;
  color: #8f9ab3;
  font-size: 11px;
}

.bulk-meta {
  margin-top: 8px;
  font-size: 12px;
  color: #8f96a8;
}

.bulk-chip-row {
  margin-top: 10px;
  display: flex;
  gap: 8px;
}

.bulk-chip {
  font-size: 11px;
  color: #8ec5ff;
  background: #17283f;
  border: 1px solid #284d7a;
  padding: 4px 8px;
  border-radius: 999px;
}

.bulk-actions {
  margin-top: 10px;
}

.bulk-actions button {
  width: 100%;
  margin-bottom: 0;
  padding: 9px 10px;
  font-size: 12px;
  border-radius: 10px;
}

.bulk-del {
  width: 24px !important;
  height: 24px;
  padding: 0 !important;
  border-radius: 50%;
  font-size: 13px;
  background: #1e222b;
  border: 1px solid #2b2f36;
  color: #868ea0;
  cursor: pointer;
}

.bulk-del:hover {
  color: #ff8f8f;
  background: #2a1a1a;
  border-color: #ff6b6b66;
}


#viewBulk .detail-header {
  margin-top: 26px;
}

#viewReelsTracking .detail-header {
  margin-top: 26px;
}

#trackingPostsGrid {
  margin-top: 10px;
}

#reelsTrackingPostsGrid {
  margin-top: 10px;
}

#trackingPostsGrid:empty::before {
  content: "Новых постов пока нет. Добавьте конкурентов и запустите выгрузку.";
  display: block;
  text-align: center;
  color: #7f8899;
  font-size: 13px;
  padding: 28px 16px;
  border: 1px dashed #2a3345;
  border-radius: 12px;
  background: #121722;
}

#reelsTrackingPostsGrid:empty::before {
  content: "Новых Reels пока нет. Добавьте конкурентов и запустите выгрузку.";
  display: block;
  text-align: center;
  color: #7f8899;
  font-size: 13px;
  padding: 28px 16px;
  border: 1px dashed #2a3345;
  border-radius: 12px;
  background: #121722;
}

.competitor-card {
  background: #13161d;
  border: 1px solid #252930;
  border-radius: 14px;
  padding: 18px;
  cursor: pointer;
  transition: border-color .2s, background .2s, transform .15s, box-shadow .2s;
  position: relative;
  overflow: hidden;
}
.competitor-card::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  background: linear-gradient(135deg, #4d8ef710, #7b5ea710);
  transition: opacity .2s;
  pointer-events: none;
}
.competitor-card:hover { border-color: #4d8ef755; transform: translateY(-2px); box-shadow: 0 6px 24px #0005; }
.competitor-card:hover::before { opacity: 1; }

/* delete btn */
.competitor-delete-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 24px;
  height: 24px;
  background: #1e222b;
  border: 1px solid #2b2f36;
  border-radius: 50%;
  color: #666;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .15s, color .15s, background .15s, border-color .15s;
  z-index: 2;
  padding: 0;
}
.competitor-card:hover .competitor-delete-btn { opacity: 1; }
.competitor-delete-btn:hover { color: #ff6b6b; background: #2a1a1a; border-color: #ff6b6b66; }

.cc-ig-link {
  position: absolute;
  top: 10px;
  right: 40px;
  width: 24px;
  height: 24px;
  background: #1e222b;
  border: 1px solid #2b2f36;
  border-radius: 50%;
  color: #888;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .15s, color .15s, background .15s, border-color .15s;
  z-index: 2;
  text-decoration: none;
}
.competitor-card:hover .cc-ig-link { opacity: 1; }
.cc-ig-link:hover { color: #e1306c; background: #e1306c18; border-color: #e1306c66; }

/* avatar + name row */
.cc-top { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }

.cc-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  letter-spacing: .5px;
  overflow: hidden;
}

.cc-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cc-info { flex: 1; min-width: 0; }

.cc-name {
  font-size: 15px;
  font-weight: 600;
  color: #ebedf0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cc-date { font-size: 11px; color: #555; margin-top: 3px; }

/* stats row */
.cc-stats {
  display: flex;
  gap: 16px;
  border-top: 1px solid #1e222a;
  padding-top: 12px;
}

.cc-stat {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: #7a8090;
}
.cc-stat svg { opacity: .6; flex-shrink: 0; }

.reel-competitor-card {
  max-width: 430px;
  padding: 18px 20px;
}

.reel-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  padding-bottom: 12px;
  border-bottom: 1px solid #232835;
}

.reel-avatar {
  width: 56px;
  height: 56px;
}

.reel-name {
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}

.reel-ig-btn {
  margin-top: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  padding: 0 12px;
  border-radius: 8px;
  background: #1f2430;
  border: 1px solid #343b4a;
  color: #d8deea;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}

.reel-ig-btn:hover {
  background: #2a3140;
}

.reel-strip {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.reel-strip-item {
  background: #121722;
  border: 1px solid #293247;
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.reel-strip-item span {
  color: #9fb0cc;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.reel-strip-item strong {
  font-size: 16px;
  color: #fff;
}

/* ---- Card ---- */
.card {
  background: #171a21;
  border: 1px solid #2b2f36;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 16px;
}

.card h2,
.card h3 {
  margin-bottom: 12px;
  font-size: 16px;
}

.hint {
  font-size: 12px;
  color: #888;
  margin-top: 6px;
}

/* ---- Inputs & Buttons ---- */
input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #2d3340;
  margin-bottom: 8px;
  background: #11141b;
  color: #ebedf0;
  font-size: 14px;
  outline: none;
}

input:focus {
  border-color: #4d8ef7;
}

button {
  width: 100%;
  padding: 10px 16px;
  border-radius: 8px;
  border: 0;
  margin-bottom: 8px;
  background: #2f6df6;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

button:hover {
  background: #1b5de0;
}

button:active {
  background: #1550c8;
}

.btn-sm {
  width: auto !important;
  padding: 6px 16px !important;
  font-size: 13px !important;
  margin-bottom: 0 !important;
}

.btn-secondary {
  background: #2b2f36;
  color: #ccc;
}

.btn-secondary:hover {
  background: #3a3f4a;
}

.btn-compact {
  width: auto !important;
  min-width: 120px;
  padding: 8px 12px !important;
  font-size: 12px !important;
}

.btn-export-inline {
  min-width: 78px;
  padding: 8px 10px !important;
}

.settings-card {
  padding: 14px;
}

.settings-subtitle {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 600;
  color: #c5d0e6;
}

#settingsLimitsCard {
  max-width: 560px;
  background: #141a24;
  border: 1px solid #2a3345;
  border-radius: 12px;
  margin-bottom: 14px;
}

.limits-reset {
  font-size: 11px;
  color: #8f96a8;
  margin-bottom: 8px;
}

.limits-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: #cfd5e2;
  padding: 6px 0;
  border-top: 1px solid #212a3b;
}

.limits-row:first-of-type {
  border-top: 0;
}

.limits-row b {
  color: #8ec5ff;
  font-size: 12px;
}

.settings-row {
  align-items: center;
  gap: 10px;
}

.settings-check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: #cfd5e2;
  margin: 10px 0 12px;
}

.settings-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
}

.settings-state {
  margin-left: auto;
  font-size: 11px;
  line-height: 1;
  padding: 5px 8px;
  border-radius: 999px;
  border: 1px solid #2c3f62;
  background: #121d31;
  color: #8ec5ff;
}

/* ---- Posts grid ---- */
.grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  column-gap: 16px;
  row-gap: 18px;
  margin-top: 16px;
}

/* Мягкое обновление при смене сортировки: старый контент виден до ответа API */
.grid.grid-refreshing,
.table-wrap.grid-refreshing {
  position: relative;
  pointer-events: none;
  opacity: 0.72;
  transition: opacity 0.15s ease;
}
.grid.grid-refreshing::after,
.table-wrap.grid-refreshing::after {
  content: "Обновление…";
  position: absolute;
  left: 50%;
  top: 10px;
  transform: translateX(-50%);
  z-index: 4;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  color: #c5d0e6;
  background: rgba(18, 23, 34, 0.92);
  border: 1px solid #2f3b52;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  white-space: nowrap;
}

.load-more-wrap {
  display: flex;
  justify-content: center;
  margin-top: 12px;
}

.load-more-wrap button {
  width: auto;
  min-width: 220px;
  margin-bottom: 0;
}

.oneoff-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  justify-content: stretch;
  align-items: start;
}

@media (max-width: 1480px) {
  .oneoff-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 1180px) {
  .oneoff-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .oneoff-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

.oneoff-error-card {
  padding: 12px;
  border-radius: 10px;
  border: 1px solid #5c2a2a;
  background: #1a1212;
  color: #e8e0e0;
}

.oneoff-error-title {
  font-weight: 600;
  color: #ff8a8a;
  margin: 0 0 8px;
}

.oneoff-error-text {
  margin: 0 0 8px;
  font-size: 13px;
  word-break: break-word;
}

.settings-checklist {
  margin: 0;
  padding-left: 1.2em;
  color: #9ba3b6;
  font-size: 13px;
  line-height: 1.5;
}

.settings-checklist li {
  margin-bottom: 8px;
}

.settings-checklist code {
  font-size: 12px;
  color: #c5d4f0;
}

.oneoff-item {
  position: relative;
}

.oneoff-item .post {
  margin: 0;
}

.oneoff-reel-tools {
  margin-top: 8px;
  display: flex;
  gap: 8px;
}

.oneoff-reel-tools button {
  width: auto;
  min-width: 120px;
  margin-bottom: 0;
  padding: 8px 10px;
  font-size: 12px;
}

.oneoff-remove {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 24px !important;
  height: 24px;
  min-width: 24px;
  padding: 0 !important;
  margin: 0 !important;
  border-radius: 50%;
  border: 1px solid #2b2f36;
  background: #1e222b;
  color: #8f96a8;
  font-size: 13px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s, color .15s, background .15s, border-color .15s;
  z-index: 4;
}

.oneoff-item:hover .oneoff-remove {
  opacity: 1;
}

.oneoff-remove:hover {
  color: #ff6b6b;
  background: #2a1a1a;
  border-color: #ff6b6b66;
}

/* Разовая выгрузка: скелетон в стиле основной карточки (.post) */
.oneoff-item.oneoff-loading .post.oneoff-skeleton {
  pointer-events: none;
}
.post.oneoff-skeleton {
  border-color: #323844;
}
.post.oneoff-skeleton:hover {
  transform: none;
  box-shadow: none;
  border-color: #323844;
}
.oneoff-skeleton-media {
  width: 100%;
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(110deg, #1a1d25 0%, #232833 45%, #1a1d25 90%);
  background-size: 200% 100%;
  animation: oneoff-shimmer 1.4s ease-in-out infinite;
}
.post.reel-card .oneoff-skeleton-media {
  height: 255px;
}
.oneoff-skeleton-label {
  font-size: 13px;
  color: #7a8499;
  text-align: center;
  padding: 0 12px;
  line-height: 1.35;
}
.oneoff-skeleton .skeleton-line.skeleton-user {
  color: #4d8ef7;
  opacity: 0.65;
}
.oneoff-skeleton .skeleton-caption {
  color: #6f7889;
  font-size: 13px;
  line-height: 1.4;
  min-height: 2.6em;
}
.oneoff-skeleton .post-actions button {
  opacity: 0.55;
  cursor: default;
}
@keyframes oneoff-shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

.post {
  position: relative;
  border: 1px solid #2b2f36;
  border-radius: 10px;
  overflow: hidden;
  background: #121722;
  transition: border-color 0.15s, transform 0.12s, box-shadow 0.15s;
}

.post:hover {
  border-color: #4d8ef7;
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.22);
}

.post-slides {
  position: relative;
  height: 220px;
  background: #1a1d25;
  cursor: pointer;
}
.post-slides img {
  width: 100%;
  height: 220px;
  object-fit: cover;
  display: block;
}
.post.reel-card .post-slides {
  height: 255px;
  background: #0f131c;
}
.post.reel-card .post-slides img {
  height: 255px;
  object-fit: contain;
  object-position: center center;
}
.post-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  background: rgba(0,0,0,0.55);
  border: none;
  color: #fff;
  font-size: 16px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .15s;
  z-index: 2;
}
.post:hover .post-arrow { opacity: 1; }
.post-arrow:hover { background: rgba(0,0,0,0.75); }
.post-arrow.prev { left: 6px; }
.post-arrow.next { right: 6px; }
.post-counter {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0,0,0,0.6);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  color: #fff;
}
.post-link {
  position: static;
  background: rgba(0,0,0,0.6);
  padding: 0 10px;
  border-radius: 6px;
  font-size: 11px;
  color: #fff;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  opacity: 1;
  transition: opacity .15s, background .15s;
  z-index: 1;
  height: 26px;
  line-height: 26px;
}
.post-link:hover { background: rgba(0,0,0,0.85); }
.post-link-visible {
  opacity: 1;
  background: rgba(0,0,0,0.75);
  border: 1px solid rgba(255,255,255,0.18);
}

.post-top-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  align-items: stretch;
  height: 26px;
  gap: 6px;
  z-index: 4;
  opacity: 0;
  transition: opacity .15s;
}

.post:hover .post-top-actions,
.oneoff-item:hover .post-top-actions {
  opacity: 1;
}

.post-remove-btn {
  width: 24px !important;
  height: 26px !important;
  min-width: 24px;
  padding: 0 !important;
  border-radius: 50%;
  border: 1px solid #2b2f36;
  background: #1e222b;
  color: #8f96a8;
  font-size: 12px;
  line-height: 26px;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  appearance: none;
}

.post-remove-btn:hover {
  color: #ff6b6b;
  background: #2a1a1a;
  border-color: #ff6b6b66;
}

.modal-slide-link {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 11px;
  z-index: 5;
}

.no-img {
  height: 220px;
  background: #1a1d25;
  display: grid;
  place-items: center;
  color: #555;
  font-size: 13px;
}

.post-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 126px;
}

.post-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.post-body b {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.post-badge {
  flex-shrink: 0;
  font-size: 10px;
  color: #9fc2ff;
  background: #1a2740;
  border: 1px solid #2f4670;
  padding: 3px 7px;
  border-radius: 999px;
}

.post-meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-height: 42px;
  align-content: flex-start;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
}

.meta-like {
  color: #ffc1cf;
  background: #3a1f2a;
  border-color: #834055;
}

.meta-comment {
  color: #b9d5ff;
  background: #1b2a40;
  border-color: #355483;
}

.meta-sync {
  color: #ffe9ad;
  background: #3b2c12;
  border-color: #7a5d28;
  max-width: 170px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sync-dot {
  width: 10px;
  height: 10px;
  border: 2px solid rgba(255, 233, 173, 0.45);
  border-top-color: #ffe9ad;
  border-radius: 50%;
  display: inline-block;
  animation: spin-sync 1s linear infinite;
}

@keyframes spin-sync {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.post-date-chip {
  margin-left: auto;
  font-size: 10px;
  color: #9ca9c2;
  background: #171d2a;
  border: 1px solid #2a3244;
  border-radius: 999px;
  padding: 3px 7px;
}

.post-caption {
  font-size: 11px;
  color: #b7c0d3;
  line-height: 1.35;
  min-height: 30px;
  height: 30px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-body button {
  margin-top: auto;
  padding: 6px 12px;
  font-size: 12px;
  width: 100%;
}

.post-actions {
  margin-top: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.post-actions button {
  margin-top: 0;
}

.reels-table-ig-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  margin-left: 6px;
}

.favorite-btn {
  background: #2b2f36;
  color: #d3dae8;
}

.favorite-btn:hover {
  background: #3a3f4a;
}

.favorite-btn.active {
  background: #4a3420;
  color: #ffd46b;
  border: 1px solid #7a5a2b;
}

/* ---- Jobs list ---- */
.job-item {
  padding: 8px 0;
  border-bottom: 1px solid #2b2f36;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
}

.job-item:last-child {
  border-bottom: 0;
}

.job-item button {
  width: auto;
  min-width: 88px;
  padding: 6px 10px;
  margin-bottom: 0;
  font-size: 12px;
}

.status-queued {
  color: #f5a623;
}

.status-running {
  color: #4d8ef7;
}

.status-succeeded {
  color: #4caf50;
}

.status-failed {
  color: #f44336;
}

/* ---- Modal ---- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.7);
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-content {
  position: relative;
  width: min(860px, 95vw);
  max-height: 94vh;
  overflow: hidden;
  background: #171a21;
  border: 1px solid #2b2f36;
  border-radius: 14px;
  padding: 24px;
}

.close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px !important;
  padding: 4px !important;
  font-size: 18px;
  background: #2b2f36;
  border-radius: 6px;
  line-height: 1;
  margin: 0 !important;
  z-index: 10;
}

/* ---- Post detail (two-column) ---- */
.post-detail {
  display: flex;
  flex-direction: row;
  gap: 20px;
  margin-top: 8px;
  align-items: flex-start;
}

.post-detail-left {
  flex-shrink: 0;
  width: 360px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.post-detail-right {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  max-height: calc(94vh - 70px);
}

/* ---- Carousel ---- */
.carousel {
  position: relative;
  background: #0d0f14;
  border-radius: 12px;
  overflow: hidden;
  width: 360px;
  height: 450px; /* 4:5 ratio */
  flex-shrink: 0;
}

.carousel img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.carousel .no-slide {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: #555;
  font-size: 14px;
}

.carousel-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px !important;
  height: 36px;
  padding: 0 !important;
  margin: 0 !important;
  border-radius: 50% !important;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 0;
  opacity: 0;
  transition: opacity 0.15s;
}

.carousel:hover .carousel-arrow {
  opacity: 1;
}

.carousel-arrow.prev {
  left: 8px;
}

.carousel-arrow.next {
  right: 8px;
}

.carousel-arrow:hover {
  background: rgba(0, 0, 0, 0.8) !important;
}

.carousel-counter {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 12px;
}

.carousel-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 4px 0;
}

.carousel-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #3a3f4a;
  cursor: pointer;
  transition: background 0.15s;
}

.carousel-dot.active {
  background: #4d8ef7;
}

/* ---- Post detail: header ---- */
.pd-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pd-header .pd-user {
  font-size: 15px;
  font-weight: 600;
  color: #ebedf0;
}

.pd-header .pd-date {
  font-size: 12px;
  color: #888;
}

.pd-link {
  font-size: 12px;
  color: #4d8ef7;
  text-decoration: none;
  margin-right: 44px;
}

.pd-link:hover {
  text-decoration: underline;
}

/* ---- Metrics grid ---- */
.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.metric-card {
  background: #11141b;
  border: 1px solid #2b2f36;
  border-radius: 10px;
  padding: 10px 12px;
  text-align: center;
  transition: border-color .2s;
}
.metric-card:hover { border-color: #404550; }

.metric-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 4px;
}
.metric-icon svg { width: 16px; height: 16px; opacity: .7; }

.metric-likes .metric-icon svg   { color: #ff6b81; }
.metric-comments .metric-icon svg { color: #74b9ff; }
.metric-views .metric-icon svg    { color: #a29bfe; }
.metric-score .metric-icon svg    { color: #ffd32a; }
.metric-slides .metric-icon svg   { color: #55efc4; }
.metric-engagement .metric-icon svg { color: #fd79a8; }

.metric-likes   { border-top: 2px solid #ff6b8133; }
.metric-comments { border-top: 2px solid #74b9ff33; }
.metric-views   { border-top: 2px solid #a29bfe33; }
.metric-score   { border-top: 2px solid #ffd32a33; }
.metric-slides  { border-top: 2px solid #55efc433; }
.metric-engagement { border-top: 2px solid #fd79a833; }

.metric-card .metric-value {
  font-size: 18px;
  font-weight: 700;
  color: #ebedf0;
}

.metric-card .metric-label {
  font-size: 11px;
  color: #888;
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.reels-metrics-grid .metric-value {
  font-size: 30px;
}

/* ---- Caption ---- */
.pd-section-title {
  font-size: 13px;
  font-weight: 600;
  color: #8eb8ff;
  margin-bottom: 6px;
}

.pd-caption {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
  color: #c4c9d4;
  line-height: 1.6;
  padding: 12px;
  background: #11141b;
  border-radius: 8px;
  max-height: 220px;
  overflow: auto;
}

.ocr-block {
  margin-top: 6px;
}

.ocr-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.ocr-actions button {
  width: 100%;
  margin-bottom: 0;
  padding: 10px 12px;
  min-height: 40px;
  border-radius: 10px;
  font-weight: 600;
}

.ocr-result {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
  color: #c4c9d4;
  line-height: 1.6;
  padding: 12px;
  background: #11141b;
  border-radius: 8px;
  max-height: none;
  overflow: visible;
  border: 1px solid #222936;
}

/* ---- Keywords pills ---- */
.pd-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.kw-pill {
  background: #1e2536;
  color: #8eb8ff;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 12px;
}

/* ---- Post detail: loading ---- */
.pd-loading {
  text-align: center;
  padding: 60px 20px;
  color: #888;
  font-size: 14px;
}

.empty-state {
  text-align: center;
  padding: 40px 24px;
  color: #666;
  font-size: 14px;
}

/* ---- Admin ---- */
.admin-kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.admin-kpi {
  background: #121722;
  border: 1px solid #273146;
  border-radius: 10px;
  padding: 14px;
}

.admin-kpi-title {
  font-size: 12px;
  color: #91a0bc;
  margin-bottom: 8px;
}

.admin-kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: #ebedf0;
}

.admin-kpi-sub {
  margin-top: 4px;
  font-size: 12px;
  color: #7c889f;
}

.admin-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.admin-table thead th {
  text-align: left;
  color: #8f9bb1;
  font-weight: 600;
  border-bottom: 1px solid #283041;
  padding: 8px 6px;
}

.admin-table tbody td {
  border-bottom: 1px solid #1f2431;
  padding: 8px 6px;
  color: #d4dae6;
  vertical-align: top;
}

.table-pagination {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  font-size: 12px;
  color: #9ba7bd;
}

.table-wrap {
  margin-top: 16px;
  overflow-x: auto;
}

.view-toggle {
  display: inline-flex;
  border: 1px solid #2c3447;
  border-radius: 10px;
  overflow: hidden;
}

.view-toggle-btn {
  width: auto !important;
  margin: 0 !important;
  padding: 8px 12px !important;
  border: 0;
  background: #161c28;
  color: #a8b3c7;
  font-size: 12px !important;
  font-weight: 600;
}

.view-toggle-btn.active {
  background: #2f6df6;
  color: #fff;
}

.reels-table td .btn-sm {
  margin-right: 6px !important;
}

.reels-table-transcribe-btn {
  margin-right: 0 !important;
  min-width: 120px;
}

.reels-table-preview {
  width: 34px;
  height: 48px;
  border-radius: 7px;
  object-fit: cover;
  border: 1px solid #2a3142;
  background: #121722;
  display: block;
}

.reels-table-user {
  color: #f2f6ff;
  font-weight: 700;
}

.reels-table-caption {
  max-width: 300px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #b7c2d7;
}

.reels-table-text-row td {
  background: #0f1420;
}

.reels-table-text {
  white-space: pre-wrap;
  color: #d2d8e4;
  font-size: 13px;
  line-height: 1.45;
  padding: 8px 0;
}

.reels-text-chip {
  display: inline-flex;
  align-items: center;
  max-width: 220px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid #2f3a51;
  color: #cfe0ff;
  background: #131a28;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reels-text-chip-open {
  cursor: pointer;
}

.reels-text-modal {
  max-width: 760px;
  border: 1px solid #2a3350;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  background: linear-gradient(180deg, #111725 0%, #0f1522 100%);
}

.reels-text-modal .pd-section-title {
  margin-top: 10px;
}

.reels-text-modal .ocr-result {
  min-height: 70px;
}

.reels-text-modal .ocr-actions {
  margin-top: 12px;
  display: flex;
  gap: 10px;
}

.reels-text-modal .ocr-actions button {
  width: auto;
  min-width: 140px;
}

.admin-link {
  color: #8eb8ff;
  text-decoration: none;
}

.admin-link:hover {
  text-decoration: underline;
}


/* Мобильная шапка/оверлей не нужны на широких экранах */
@media (min-width: 769px) {
  .mobile-top-bar,
  .mobile-overlay {
    display: none !important;
  }
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  /* Mobile Top Bar (Header) — видна только после syncMobileChrome() в app.js */
  .mobile-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 52px;
    padding: 8px 16px;
    padding-top: max(10px, env(safe-area-inset-top, 0px));
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
    background: #10141d;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1200;
    padding-bottom: 10px;
    border-bottom: 1px solid #1a1e26;
    box-sizing: border-box;
  }
  .mobile-logo {
    font-size: 17px;
    font-weight: 700;
    color: #fff;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .mobile-menu-btn {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    margin: 0;
    padding: 0;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    color: #fff;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-menu-btn:active {
    background: rgba(255, 255, 255, 0.12);
  }
  .mobile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 1250;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-overlay.hidden {
    display: none;
  }

  .app-layout {
    margin-top: calc(52px + max(10px, env(safe-area-inset-top, 0px)) + 10px);
    min-height: calc(100vh - 52px - max(10px, env(safe-area-inset-top, 0px)) - 20px);
    min-height: calc(100dvh - 52px - max(10px, env(safe-area-inset-top, 0px)) - 20px);
    box-sizing: border-box;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    transition: transform 0.28s ease;
    z-index: 1300;
    width: min(300px, 88vw) !important;
    min-width: 0 !important;
    max-width: 300px;
    background: #10141d;
    border-right: 1px solid #1a1e26;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.45);
  }
  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-logo,
  .sidebar-logo h2,
  .nav-link span:not(.nav-link-label):not(.nav-soon-badge),
  .sidebar-footer .user-info,
  .nav-group-title {
    display: block !important;
  }

  .nav-link .nav-link-label,
  .nav-link .nav-soon-badge {
    display: inline-flex !important;
    align-items: center;
  }

  .nav-link .nav-link-label {
    flex: 1 1 auto;
    min-width: 0;
  }

  .nav-link {
    justify-content: flex-start !important;
    padding: 10px 16px !important;
  }

  .main-area {
    margin-left: 0 !important;
    padding: 16px;
    padding-bottom: max(24px, env(safe-area-inset-bottom, 16px));
    width: 100%;
  }

  .modal {
    padding: 8px;
    align-items: flex-end;
    z-index: 1400;
  }

  .modal-content {
    width: 100%;
    max-width: 100%;
    max-height: 98vh;
    border-radius: 12px;
    padding: 14px;
  }

  .form-row {
    flex-direction: column;
  }

  .analyze-card {
    padding: 16px;
  }
  .analyze-card h2 {
    font-size: 24px;
  }
  .analyze-row {
    flex-direction: column;
    align-items: stretch;
  }
  .analyze-limit,
  .analyze-btn {
    width: 100%;
    min-width: 0;
  }

  .form-row input[type="number"] {
    width: 100%;
  }

  .form-row button {
    width: 100%;
  }

  .grid {
    grid-template-columns: repeat(1, minmax(0, 1fr));
  }

  .oneoff-grid {
    grid-template-columns: repeat(1, minmax(0, 1fr));
  }

  .competitors-grid {
    grid-template-columns: 1fr;
  }

  .bulk-grid {
    grid-template-columns: 1fr;
  }

  .reel-strip {
    grid-template-columns: 1fr;
  }

  .admin-kpi-grid {
    grid-template-columns: 1fr;
  }

  .admin-panels {
    grid-template-columns: 1fr;
  }

  .admin-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  .detail-header {
    flex-direction: column;
    gap: 12px;
  }

  .detail-actions {
    width: 100%;
    flex-wrap: wrap;
    gap: 8px;
  }

  .detail-actions .sort-select {
    flex: 1 1 100%;
  }

  .detail-actions .view-toggle {
    width: 100%;
  }

  .post-detail {
    flex-direction: column;
  }

  #settingsLimitsCard {
    max-width: none;
  }

  .post-detail-left {
    width: 100%;
  }

  .carousel {
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 5;
  }

  .post-detail-right {
    max-height: none;
  }

  .detail-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .detail-actions {
    width: 100%;
    justify-content: space-between;
  }

  .sort-select {
    flex: 1;
    min-width: 0;
  }

  .ocr-actions {
    flex-direction: column;
  }

  .ocr-actions button {
    width: 100%;
  }

}

@media (max-width: 1120px) and (min-width: 769px) {
  .grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

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

  .oneoff-grid {
    grid-template-columns: repeat(2, minmax(300px, 300px));
    justify-content: start;
  }

  .admin-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-panels {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1440px) and (min-width: 1121px) {
  .grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
