body {
  background: #f5efe6;
  overflow-x: hidden;
}

:root[data-theme="dark"] body {
  background: radial-gradient(circle at top left, rgba(46, 107, 255, 0.22), transparent 55%),
    radial-gradient(circle at 15% 20%, rgba(42, 185, 196, 0.15), transparent 48%),
    linear-gradient(180deg, #071733 0%, #0a1c3b 46%, #0d2550 100%);
}

.admin-login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.admin-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas: "top top" "side main";
  min-height: 100vh;
  max-width: 100vw;
  overflow-x: hidden;
}

.admin-sidebar {
  grid-area: side;
  background: var(--nav-bg);
  color: var(--nav-ink);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.admin-sidebar *,
.admin-main,
.admin-view {
  min-width: 0;
}

.admin-sidebar .notifications-panel {
  left: 18px;
  right: auto;
  max-width: calc(100vw - 36px);
}

.admin-sidebar .notification-button {
  color: var(--nav-ink);
}

.admin-sidebar .icon-button {
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-brand {
  font-size: 1.2rem;
  font-weight: 700;
}

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

.sidebar-actions {
  display: grid;
  gap: 12px;
}

.sidebar-link {
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  color: inherit;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 0.95rem;
  cursor: pointer;
  width: 100%;
}

.sidebar-link.is-active,
.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.08);
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 12px;
}

.sidebar-user {
  font-size: 0.9rem;
  color: var(--nav-muted);
}

.admin-main {
  grid-area: main;
  padding: 28px 32px 60px;
  overflow-x: hidden;
  min-width: 0;
}

.admin-view {
  display: grid;
  gap: 18px;
}

.view-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.view-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.filters {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.field.inline {
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
}

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

.form-grid.compact {
  grid-template-columns: minmax(140px, 1fr) auto;
  align-items: end;
}

.action-field {
  justify-content: end;
}

.table-wrap {
  background: white;
  border-radius: 14px;
  border: 1px solid var(--border);
  overflow-x: auto;
}


.users-toolbar {
  display: flex;
  align-items: end;
  gap: 12px;
  margin-bottom: 12px;
}

.search-field {
  max-width: 360px;
  width: min(100%, 360px);
}

.search-hint {
  min-height: 20px;
  padding-bottom: 10px;
}

.admin-clickable-row {
  cursor: pointer;
}

.admin-clickable-row .button,
.admin-clickable-row a,
.admin-clickable-row input,
.admin-clickable-row select {
  cursor: auto;
}

.modal-content-wide {
  width: min(960px, calc(100vw - 32px));
  max-height: min(860px, calc(100vh - 32px));
  overflow: auto;
}

.user-detail-layout {
  display: grid;
  gap: 18px;
}

.user-detail-hero {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 18px;
}

.user-detail-avatar {
  width: 112px;
  height: 112px;
  border-radius: 24px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.user-detail-hero h4,
.user-detail-layout h4 {
  margin: 0 0 6px;
}

.user-detail-hero p {
  margin: 0;
  color: var(--muted);
}

.user-detail-badges,
.user-detail-gift-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.user-detail-badges span,
.user-detail-gift-summary span,
.status-pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text);
  background: rgba(62, 133, 255, 0.08);
}

.status-pill.is-active {
  color: #157347;
  background: rgba(21, 115, 71, 0.12);
}

.status-pill.is-expired {
  color: #b42318;
  background: rgba(180, 35, 24, 0.12);
}

.status-pill.is-redeemed {
  color: #7a4b00;
  background: rgba(245, 158, 11, 0.16);
}

.user-detail-stats.stat-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.compact-table-wrap {
  border-radius: 10px;
}

.compact-table {
  font-size: 0.82rem;
}

.compact-table th,
.compact-table td {
  padding: 9px 8px;
}

@media (max-width: 720px) {
  .users-toolbar,
  .user-detail-hero {
    display: grid;
    grid-template-columns: 1fr;
  }

  .search-field {
    width: 100%;
    max-width: none;
  }
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.admin-table th,
.admin-table td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid #eee3d4;
  vertical-align: middle;
}

.admin-table th {
  font-weight: 600;
  color: var(--muted);
  background: #fcf7f0;
}

.admin-table tbody tr:hover {
  background: #faf4ec;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 90px;
}

.tag-chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  background: rgba(62, 133, 255, 0.08);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.4;
}

.points-adjust {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.member-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

.button.small {
  padding: 6px 10px;
  font-size: 0.75rem;
  border-radius: 999px;
}

.pagination {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 0.9rem;
}

.status.warning {
  color: #b42318;
  background: #fde8e8;
  border: 1px solid #f5b4b4;
  padding: 8px 10px;
  border-radius: 10px;
}

.pagination button {
  border: 1px solid var(--border);
  background: white;
  padding: 6px 12px;
  border-radius: 10px;
  cursor: pointer;
}

.panel {
  background: white;
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 18px;
  display: grid;
  gap: 14px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.notification-compose textarea {
  min-height: 140px;
  resize: vertical;
}

.search-hint {
  font-size: 0.85rem;
}

.user-picker,
.user-selected,
.notification-history-list {
  display: grid;
  gap: 12px;
}

.user-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fcf7f0;
}

.user-row .muted {
  font-size: 0.85rem;
}

.sync-list {
  display: grid;
  gap: 12px;
}

.sync-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fcf7f0;
  flex-wrap: wrap;
}

.sync-main {
  display: grid;
  gap: 6px;
  min-width: 220px;
}

.sync-title {
  display: flex;
  gap: 12px;
  align-items: center;
}

.sync-logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  display: grid;
  place-items: center;
  overflow: hidden;
  flex: 0 0 auto;
}

.sync-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sync-name {
  font-weight: 600;
}

.sync-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}

.sync-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.sync-pill {
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 0.75rem;
  color: inherit;
}

.user-selected.is-disabled,
.user-picker.is-disabled {
  opacity: 0.6;
  pointer-events: none;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
}

.selected-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.notification-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  background: #fff;
  display: grid;
  gap: 6px;
}

.notification-card-title {
  font-weight: 600;
}

.notification-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}

@media (max-width: 760px) {
  .admin-shell {
    grid-template-columns: 1fr;
    grid-template-areas: "top" "main";
  }

  .admin-top-nav {
    display: flex;
  }

  .admin-top-nav .icon-button {
    background: rgba(255, 255, 255, 0.08);
  }

  .admin-top-nav .notification-button {
    color: #fef7ec;
  }

  .admin-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(320px, 86vw);
    min-height: 100vh;
    padding: 22px 18px;
    z-index: 40;
    transition: transform 0.25s ease;
    transform: translateX(-100%);
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 18px 0 48px rgba(3, 8, 18, 0.28);
  }

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

  .admin-sidebar .notifications-panel {
    position: fixed;
    top: 78px;
    left: 12px;
    right: 12px;
    width: auto;
    max-width: none;
  }
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--muted);
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px 12px;
  padding: 8px 0;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
}

.hint {
  font-size: 0.8rem;
  color: var(--muted);
}

.flag-preview {
  width: 140px;
  height: 90px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #faf4ec;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.flag-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.banner-preview {
  width: 100%;
  max-width: 520px;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #faf4ec;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.banner-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.group-profile-preview {
  max-width: 180px;
  aspect-ratio: 1 / 1;
}

.group-profile-preview img {
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.coupon-image-preview {
  width: 180px;
  height: 120px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #faf4ec;
  display: grid;
  place-items: center;
  overflow: hidden;
}

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

.badge-image-preview {
  width: 120px;
  height: 120px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #faf4ec;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.badge-image-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.coupon-thumb {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #faf4ec;
  object-fit: cover;
  display: block;
}

.badge-thumb {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #faf4ec;
  object-fit: cover;
  display: block;
}

.coupon-thumb.placeholder {
  display: grid;
  place-items: center;
  font-size: 0.6rem;
  color: var(--muted);
  text-align: center;
  padding: 4px;
}

.coupon-redeem-result {
  display: grid;
  gap: 6px;
  padding: 16px;
  border-radius: 14px;
  border: 1px dashed var(--border);
  background: rgba(255, 138, 90, 0.08);
}

.coupon-redeem-result span,
.coupon-redeem-result small {
  color: var(--muted);
  font-size: 0.85rem;
}

.coupon-redeem-result strong {
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: var(--accent);
}

.badge-thumb.placeholder {
  display: grid;
  place-items: center;
  font-size: 0.6rem;
  color: var(--muted);
  text-align: center;
  padding: 4px;
}

.segmented-actions {
  gap: 6px;
}

.segmented-actions .button.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

:root[data-theme="dark"] .segmented-actions .button.ghost.is-active,
:root[data-theme="dark"] .segmented-actions .button.is-active {
  background: rgba(46, 107, 255, 0.24);
  border-color: rgba(92, 145, 255, 0.7);
  color: #f4f8ff;
}

.carousel-thumb {
  width: 64px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #faf4ec;
  object-fit: cover;
  display: block;
}

.carousel-thumb.placeholder {
  display: grid;
  place-items: center;
  font-size: 0.6rem;
  color: var(--muted);
  text-align: center;
  padding: 4px;
}

:root[data-theme="dark"] .admin-main {
  color: var(--ink);
}

:root[data-theme="dark"] .table-wrap,
:root[data-theme="dark"] .panel,
:root[data-theme="dark"] .modal-content,
:root[data-theme="dark"] .notification-card {
  background: var(--surface);
  border-color: var(--border);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

:root[data-theme="dark"] .admin-table th {
  background: var(--surface-2);
  color: var(--muted);
}

:root[data-theme="dark"] .admin-table td,
:root[data-theme="dark"] .admin-table th,
:root[data-theme="dark"] .standings-table td,
:root[data-theme="dark"] .standings-table th {
  border-bottom-color: var(--border);
}

:root[data-theme="dark"] .admin-table tbody tr:hover,
:root[data-theme="dark"] .user-row,
:root[data-theme="dark"] .sync-row,
:root[data-theme="dark"] .standings-card,
:root[data-theme="dark"] .flag-preview,
:root[data-theme="dark"] .banner-preview,
:root[data-theme="dark"] .coupon-image-preview,
:root[data-theme="dark"] .badge-image-preview,
:root[data-theme="dark"] .coupon-thumb,
:root[data-theme="dark"] .badge-thumb,
:root[data-theme="dark"] .carousel-thumb {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--ink);
}

:root[data-theme="dark"] .sync-pill,
:root[data-theme="dark"] .user-chip,
:root[data-theme="dark"] .pagination button,
:root[data-theme="dark"] .icon-button {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--ink);
}

:root[data-theme="dark"] .status.warning {
  color: #ffc2c2;
  background: rgba(180, 35, 24, 0.2);
  border-color: rgba(255, 133, 133, 0.32);
}

:root[data-theme="dark"] .notification-card-meta,
:root[data-theme="dark"] .sidebar-user {
  color: var(--muted);
}

.standings {
  display: grid;
  gap: 12px;
  margin-top: 8px;
}

.standings-card {
  background: #faf4ec;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}

.standings-card h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.standings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.standings-table th,
.standings-table td {
  padding: 6px 4px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 10, 6, 0.4);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 50;
}

.modal[data-dialog-modal] {
  z-index: 80;
}

.modal-content {
  background: white;
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 20px;
  width: min(560px, 92vw);
  display: grid;
  gap: 14px;
}

.dialog-animation {
  width: 92px;
  height: 92px;
  margin: 0 auto -4px;
}

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

.icon-button {
  border: none;
  background: #f2e7d6;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
}

.is-hidden {
  display: none !important;
}

.split-grid > * {
  min-width: 0;
}

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

.stat-grid.compact {
  margin-bottom: 18px;
}

.stat-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: var(--surface-2);
}

.stat-card strong {
  display: block;
  font-size: 1.25rem;
}

.stat-card span {
  color: var(--muted);
  font-size: 0.82rem;
}

.two-column-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 18px;
}

.two-column-grid h4 {
  margin: 0 0 10px;
}

.two-column-grid > * {
  min-width: 0;
}

@media (max-width: 920px) {
  .admin-shell {
    grid-template-columns: 1fr;
    grid-template-areas: "top" "main";
  }

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

  .admin-top-nav {
    display: flex;
  }

  .admin-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(320px, 86vw);
    min-height: 100vh;
    padding: 22px 18px;
    z-index: 40;
    transition: transform 0.25s ease;
    transform: translateX(-100%);
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 18px 0 48px rgba(3, 8, 18, 0.28);
  }

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

  .sidebar-nav {
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    width: 100%;
  }

  .sidebar-link {
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

@media (max-width: 640px) {
  .admin-main {
    padding: 20px 16px 48px;
  }

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