/* FairDraw Desktop & Responsive Web Dashboard Layout (Telegram Mobile Blue + Responsive Tables) */

.dash-loading {
  grid-column: 1 / -1;
  width: min(440px, calc(100% - 32px));
  margin: 48px auto;
  align-self: center;
  justify-self: center;
}

.dash-shell {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
}

/* Span full viewport when showing the unauthenticated Sign-In Gate inside .dash-shell */
.dash-shell > .auth-gate-wrap {
  grid-column: 1 / -1;
  width: 100%;
}

.auth-gate-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Sticky Sidebar (desktop) */
.dash-sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow-y: auto;
  background: var(--surface);
  border-inline-end: 1px solid var(--border);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  z-index: 20;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px;
}

.sidebar-brand img {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  flex: none;
  box-shadow: 0 2px 10px rgba(3, 86, 149, 0.25);
}

.sidebar-brand-title {
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.2;
}

.sidebar-brand-sub {
  color: var(--muted);
  font-size: 0.76rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: none;
  border-radius: 11px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: start;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease;
}

.nav-item:hover {
  background: var(--surface-alt);
}

.nav-item.is-active {
  background: var(--accent);
  color: var(--accent-text);
}

.nav-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.seg-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  background: var(--surface-alt);
  padding: 3px;
  border-radius: 10px;
}

.seg-group.two-col {
  grid-template-columns: repeat(2, 1fr);
}

.seg-btn {
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 6px 4px;
  cursor: pointer;
}

.seg-btn.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* Main Workspace */
.dash-main-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Compact mobile top bar (<12% viewport height per content-first-noise-reduction) */
.mobile-topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 15;
  height: 56px;
  padding: 8px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.dash-main {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 22px 24px 48px;
}

.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.demo-banner {
  background: linear-gradient(135deg, rgba(3, 86, 149, 0.12), rgba(42, 171, 238, 0.14));
  border: 1px solid rgba(42, 171, 238, 0.35);
  border-radius: 14px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
}

.kpi-val {
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1.15;
  color: var(--accent);
}

.kpi-lbl {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 4px;
}

.two-col-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(290px, 1fr);
  gap: 16px;
  align-items: start;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

/* Live Telegram Post Preview Bubble */
.tg-preview-card {
  position: sticky;
  top: 20px;
}

.tg-bubble {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.tg-inline-btns {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.tg-inline-btn {
  background: rgba(30, 120, 200, 0.14);
  color: var(--accent);
  border: 1px solid rgba(42, 171, 238, 0.3);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
}

/* Responsive Data Table per modern-web-guidance */
.table-wrapper {
  overflow: auto;
  max-inline-size: 100%;
  max-block-size: min(520px, 72dvh);
  container-type: inline-size;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.88rem;
  --label-2: "Tickets";
  --label-3: "Sources";
  --label-4: "Poll";
  --label-5: "Joined";
}

.data-table caption {
  text-align: start;
  padding: 10px 14px;
  font-weight: 700;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
}

.data-table thead {
  position: sticky;
  inset-block-start: 0;
  z-index: 1;
  background: var(--surface-alt);
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  text-align: start;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table tbody th {
  position: sticky;
  inset-inline-start: 0;
  background: var(--surface);
  font-weight: 600;
}

@container (width < 600px) {
  .data-table,
  .data-table thead,
  .data-table tbody,
  .data-table tr,
  .data-table th,
  .data-table td {
    display: block;
    white-space: normal;
  }

  .data-table thead {
    display: none;
  }

  .data-table tr {
    margin: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
  }

  .data-table tbody th {
    position: sticky;
    inset-block-start: 0;
    z-index: 2;
    background: var(--surface-alt);
  }

  .data-table td:nth-child(2)::before {
    content: var(--label-2) ": ";
    font-weight: 600;
    color: var(--muted);
  }
  .data-table td:nth-child(3)::before {
    content: var(--label-3) ": ";
    font-weight: 600;
    color: var(--muted);
  }
  .data-table td:nth-child(4)::before {
    content: var(--label-4) ": ";
    font-weight: 600;
    color: var(--muted);
  }
  .data-table td:nth-child(5)::before {
    content: var(--label-5) ": ";
    font-weight: 600;
    color: var(--muted);
  }
}

.sidebar-backdrop {
  display: none;
}

@media (max-width: 860px) {
  .dash-shell {
    grid-template-columns: 1fr;
  }

  .mobile-topbar {
    display: flex;
  }

  .dash-sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    width: 272px;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
  }

  [dir="rtl"] .dash-sidebar {
    transform: translateX(105%);
  }

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

  .sidebar-backdrop.is-open {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(10, 22, 38, 0.5);
    z-index: 19;
  }

  .dash-main {
    padding: 16px 14px 42px;
  }

  .two-col-grid {
    grid-template-columns: 1fr;
  }

  .tg-preview-card {
    position: static;
  }
}

@media (max-width: 480px) {
  .auth-gate-controls {
    grid-template-columns: 1fr;
  }
}

.network-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-scroll-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 150px;
  overflow-y: auto;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}

.owner-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 12px;
}

.owner-split-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 14px;
}

.feedback-card-unread {
  border-inline-start: 4px solid var(--accent);
}

/* Ultra Plan Cards & Direct Crypto Checkout */
.plan-tier-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.plan-tier-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-family: inherit;
  text-align: start;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.plan-tier-card.is-selected {
  border-color: var(--accent);
  background: rgba(42, 171, 238, 0.1);
  box-shadow: 0 0 0 2px rgba(42, 171, 238, 0.25);
}

.checkout-split {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.qr-frame {
  padding: 10px;
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.qr-frame svg {
  display: block;
  max-width: 100%;
  height: auto;
}

.copy-field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
}

.checkout-qr-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 222px;
  justify-self: center;
}

.checkout-qr-col .btn {
  width: 100%;
  justify-content: center;
}

.checkout-wallet-note {
  max-width: 220px;
  text-align: center;
  font-size: 0.74rem;
  line-height: 1.35;
}

.copy-field-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.copy-field-label {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.3;
}

.reroll-winner-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 6px;
}

.copy-field-val {
  min-width: 0;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
}

@media (max-width: 680px) {
  .checkout-split {
    grid-template-columns: 1fr;
  }
  .qr-frame {
    justify-self: center;
  }
}
