.admin-body { background: var(--canvas); }
.admin-sticky-header { position: sticky; top: 0; z-index: 60; }
.admin-mobile-nav { display: none; }

.admin-header {
  height: 78px;
  background: white;
  border-top: 5px solid var(--blue);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 30px;
  position: relative;
  box-shadow: 0 4px 16px rgba(16, 47, 90, .04);
}
.admin-brand { display: flex; align-items: center; gap: 18px; }
.admin-brand img { width: 210px; }
.admin-brand div { border-left: 1px solid var(--line); padding-left: 18px; line-height: 1.25; }
.admin-brand strong, .admin-brand span { display: block; }
.admin-brand strong { color: var(--blue-deep); }
.admin-brand span { font-size: 10px; text-transform: uppercase; letter-spacing: .14em; color: var(--teal-dark); font-weight: 800; }
.admin-header-actions { display: flex; align-items: center; gap: 10px; }
.admin-header-actions span { font-size: 12px; color: var(--muted); }
.admin-exit {
  text-decoration: none;
  font-size: 12px;
  font-weight: 800;
  border: 1px solid #cbdde8;
  border-radius: 7px;
  padding: 9px 13px;
  color: var(--blue-deep);
  background: white;
}
.admin-exit:hover { color: var(--blue); border-color: var(--blue); }
button.admin-exit { background: white; color: var(--blue-deep); cursor: pointer; }

.admin-shell { display: grid; grid-template-columns: 225px 1fr; min-height: calc(100vh - 78px); }
.admin-nav {
  position: relative;
  background: white;
  padding: 24px 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  border-right: 1px solid var(--line);
}
.admin-nav::after {
  content: "";
  position: absolute;
  top: 0;
  right: -1px;
  width: 3px;
  height: 74px;
  background: var(--teal);
}
.admin-nav-item {
  border: 0;
  background: transparent;
  color: #597286;
  border-radius: 7px;
  padding: 11px 14px;
  text-align: left;
  font-weight: 750;
}
.admin-nav-item:hover { background: var(--soft-blue); color: var(--blue-deep); }
.admin-nav-item.active { background: var(--blue); color: white; box-shadow: 0 7px 16px rgba(24, 114, 210, .16); }
.admin-content { padding: 38px; min-width: 0; }
.admin-page { display: none; }
.admin-page.active { display: block; animation: fade .2s; }
.admin-title { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 25px; }
.admin-title h1 { font-size: 40px; line-height: 1.15; letter-spacing: -.035em; color: var(--blue-deep); margin: 3px 0; }
.admin-title p { margin: 0; color: var(--muted); }

.summary-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.summary-cards article {
  position: relative;
  overflow: hidden;
  background: white;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.summary-cards article::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--blue); }
.summary-cards article:nth-child(even)::before { background: var(--teal); }
.summary-cards strong, .summary-cards span { display: block; }
.summary-cards strong { font-size: 32px; color: var(--blue-deep); }
.summary-cards span { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .09em; font-weight: 800; }

.admin-panel {
  background: white;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 22px;
  margin-top: 20px;
  box-shadow: var(--shadow-sm);
}
.panel-title { display: flex; align-items: center; justify-content: space-between; }
.panel-title h2 { color: var(--blue-deep); margin: 0 0 12px; letter-spacing: -.015em; }
.recent-activity-filter { display: flex; align-items: center; justify-content: flex-end; gap: 9px; margin: 0 0 14px; }
.recent-activity-filter label { color: var(--blue-deep); font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.recent-activity-filter select { width: min(280px, 100%); border: 1px solid #c9dce7; border-radius: 8px; padding: 10px 12px; background: white; }
.form-panel { border-top: 4px solid var(--teal); }
.admin-form { display: grid; gap: 18px; }
.schedule-admin-box {
  display: grid;
  gap: 14px;
  padding: 20px;
  border: 1px solid #cfe2ec;
  border-radius: 10px;
  background: var(--soft-blue);
}
.schedule-admin-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; }
.schedule-admin-heading span { display: block; color: var(--teal-dark); font-size: 9px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.schedule-admin-heading h3 { margin: 2px 0 0; color: var(--blue-deep); font-size: 19px; }
.schedule-admin-heading p { max-width: 470px; margin: 0; color: var(--muted); font-size: 12px; font-weight: 500; line-height: 1.55; }
.casino-meeting-summary { margin-top: 8px; color: var(--blue-deep); font-size: 11px; }
.casino-meeting-summary strong { color: var(--teal-dark); }
.form-grid { display: grid; gap: 14px; }
.form-grid.two { grid-template-columns: repeat(2, 1fr); }
.form-grid.three { grid-template-columns: repeat(3, 1fr); }
.admin-form label { font-size: 12px; font-weight: 800; color: var(--blue-deep); }
.admin-form small { display: block; color: var(--muted); font-weight: 400; margin-top: 4px; }
.casino-logo-field { display: grid; align-content: start; }
.casino-logo-preview {
  min-height: 112px;
  margin: 6px 0 10px;
  padding: 12px;
  border: 1px solid #c9dce7;
  border-radius: 9px;
  background: #f8fbfd;
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}
.casino-logo-preview img {
  width: 150px;
  height: 86px;
  object-fit: contain;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
}
.admin-form select, .filter-row select, .inline-form select { width: 100%; border: 1px solid #c9dce7; border-radius: 8px; padding: 13px 14px; background: white; }
.filter-row { display: flex; gap: 10px; margin-bottom: 18px; }
.filter-row input { flex: 1; }
.filter-row select { max-width: 220px; }

.casino-admin-list { display: grid; gap: 11px; }
.casino-admin-card {
  display: grid;
  grid-template-columns: 58px 1fr auto;
  align-items: center;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  background: white;
  transition: border-color .18s, box-shadow .18s;
}
.casino-admin-card:hover { border-color: #b9d7e7; box-shadow: var(--shadow-sm); }
.casino-card-logo { width: 58px; height: 58px; border-radius: 8px; background: var(--soft-blue); display: grid; place-items: center; color: var(--blue); font-weight: 800; overflow: hidden; }
.casino-card-logo img { width: 100%; height: 100%; object-fit: contain; padding: 5px; }
.casino-card-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; }
.casino-card-actions .secondary-button, .casino-card-actions .primary-button { text-decoration: none; white-space: nowrap; }
.casino-card-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.casino-card-title h3 { margin: 0; color: var(--blue-deep); }
.casino-card-main p { margin: 2px 0; color: var(--muted); }
.casino-card-main small { color: var(--muted); }
.casino-stats { display: flex; gap: 16px; font-size: 11px; color: var(--muted); margin-top: 8px; }
.casino-materials-panel { border-top: 4px solid var(--blue); }
.casino-materials-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.casino-materials-title h2 { margin: 3px 0 5px; color: var(--blue-deep); font-size: 27px; }
.casino-materials-title p { margin: 0; color: var(--muted); }
.admin-material-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; margin-top: 20px; }
.admin-material-group { overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: #fbfdfe; }
.admin-material-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--soft-blue); }
.admin-material-group[data-material-category="rooms"] .admin-material-heading { background: var(--soft-teal); }
.admin-material-group[data-material-category="features"] .admin-material-heading { background: var(--soft-blue); }
.admin-material-group[data-material-category="logos"] .admin-material-heading { background: var(--soft-teal); }
.admin-material-heading h3 { margin: 0; color: var(--blue-deep); font-size: 16px; }
.admin-material-heading span { color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.admin-material-list { display: grid; gap: 9px; padding: 12px; }
.admin-material-item { display: grid; grid-template-columns: 72px minmax(0, 1fr); align-items: center; gap: 11px; padding: 9px; border: 1px solid var(--line); border-radius: 8px; background: white; }
.admin-material-item > img, .admin-material-item > div:first-child { width: 72px; height: 55px; border-radius: 6px; background: #f2f7fa; object-fit: cover; display: grid; place-items: center; color: var(--blue); font-size: 10px; font-weight: 800; }
.admin-material-copy { display: grid; min-width: 0; gap: 3px; }
.admin-material-copy a { color: var(--blue); overflow-wrap: anywhere; }
.admin-material-copy span, .admin-material-copy small { color: var(--muted); font-size: 10px; overflow-wrap: anywhere; }
.admin-material-actions { display: flex; gap: 7px; margin-top: 6px; }
.admin-library-links { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.admin-library-links h3 { margin: 0 0 10px; color: var(--blue-deep); }
#casinoMaterialsLinks { display: grid; gap: 8px; }
.admin-library-item { display: grid; gap: 3px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 8px; background: #fbfdfe; }
.admin-library-item a { color: var(--blue); font-weight: 800; }
.admin-library-item span, .admin-library-item small { color: var(--muted); font-size: 10px; }

.portal-type-badge, .status-badge, .access-off {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
  background: var(--soft-blue);
  color: var(--blue-deep);
}
.portal-type-badge { background: var(--soft-blue); color: var(--blue-deep); }
.portal-type-badge.sponsor_only { background: var(--soft-teal); color: #16767b; }
.status-badge.onboarding, .status-badge.active { background: var(--soft-teal); color: #16767b; }
.status-badge.live, .status-badge.used { background: #e5f4ea; color: #2c7447; }
.status-badge.archived, .status-badge.expired, .status-badge.replaced { background: #eef1f3; color: #667782; }
.status-badge.signed_out { background: var(--soft-blue); color: var(--blue-deep); }
.access-off { background: #f7e5e7; color: #943a44; }

.admin-table-wrap { overflow: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.admin-table th { text-align: left; color: #587286; font-size: 9px; text-transform: uppercase; letter-spacing: .09em; padding: 11px 10px; border-bottom: 2px solid #cfe2ec; white-space: nowrap; background: #f8fbfd; }
.admin-table td { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.admin-table tr:hover td { background: #f7fbfd; }
.table-actions { display: flex; gap: 5px; white-space: nowrap; }
.mini-button { display: inline-flex; align-items: center; justify-content: center; width: fit-content; border: 0; background: var(--soft-blue); color: var(--blue); border-radius: 6px; padding: 5px 8px; font-size: 10px; font-weight: 800; text-decoration: none; }
.mini-button:hover { background: #dceef9; }
.mini-button.danger { background: #f7e6e8; color: var(--danger); }
.muted { color: var(--muted); font-size: 11px; }
.important-note { background: linear-gradient(90deg, var(--soft-blue), var(--soft-teal)); border-color: #d4e9ed; color: var(--blue-deep); }
.inline-form { display: grid; grid-template-columns: 1fr 180px auto; gap: 10px; margin-bottom: 20px; }
.admin-role-form { grid-template-columns: 1fr 220px 150px auto; }
.fatal-panel { max-width: 700px; margin: 50px auto; background: white; border: 1px solid var(--line); border-radius: 12px; padding: 36px; box-shadow: var(--shadow-sm); }
.fatal-panel h1 { color: var(--blue-deep); }

/* Admin access gate */
.admin-login-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(90deg, var(--blue) 0 65%, var(--teal) 65%) top / 100% 7px no-repeat,
    radial-gradient(circle at 85% 15%, rgba(40, 170, 175, .13), transparent 28%),
    radial-gradient(circle at 10% 80%, rgba(24, 114, 210, .1), transparent 30%),
    #f8fbfd;
}
.admin-login-gate[hidden] { display: none; }
.admin-login-card {
  position: relative;
  overflow: hidden;
  width: min(480px, 100%);
  background: white;
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 36px;
  box-shadow: var(--shadow);
}
.admin-login-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 5px; background: linear-gradient(90deg, var(--blue), var(--teal)); }
.admin-login-card > img { width: 235px; max-width: 100%; margin-bottom: 25px; }
.admin-login-card h1 { color: var(--blue-deep); font-size: 37px; line-height: 1.15; letter-spacing: -.035em; margin: 5px 0 12px; }
.admin-login-card > p { color: var(--muted); line-height: 1.65; }
.admin-login-form { display: grid; gap: 14px; margin-top: 22px; }
.admin-login-form label { font-size: 12px; font-weight: 800; color: var(--blue-deep); }
.admin-login-form input { margin-top: 7px; }
.admin-login-message { min-height: 24px; margin: 16px 0 0 !important; color: var(--blue-deep) !important; font-weight: 700; }

@media (max-width: 1100px) {
  .summary-cards { grid-template-columns: repeat(2, 1fr); }
  .form-grid.three { grid-template-columns: 1fr 1fr; }
  .admin-shell { grid-template-columns: 185px 1fr; }
  .admin-content { padding: 28px 20px; }
}
@media (max-width: 760px) {
  .admin-sticky-header { box-shadow: 0 4px 16px rgba(16, 47, 90, .06); }
  .admin-header { height: 64px; min-height: 64px; padding: 9px 14px; }
  .admin-brand img { width: 150px; }
  .admin-brand div { display: none; }
  .admin-mobile-nav {
    display: flex;
    gap: 5px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    padding: 7px 9px 9px;
    background: white;
    border-bottom: 1px solid var(--line);
  }
  .admin-mobile-nav::-webkit-scrollbar { display: none; }
  .admin-mobile-nav .admin-nav-item { flex: 0 0 auto; min-height: 36px; padding: 8px 11px; white-space: nowrap; font-size: 11px; }
  .admin-desktop-nav { display: none; }
  .admin-shell { display: block; min-height: calc(100vh - 116px); }
  .admin-content { padding: 24px 14px; }
  .admin-title h1 { font-size: 33px; }
  .admin-title { display: block; }
  .admin-title > button { margin-top: 12px; }
  .summary-cards { grid-template-columns: 1fr 1fr; }
  .form-grid.two, .form-grid.three, .inline-form { grid-template-columns: 1fr; }
  .casino-admin-card { grid-template-columns: 48px 1fr; }
  .casino-card-actions { grid-column: 1 / -1; justify-content: stretch; }
  .casino-card-actions .secondary-button, .casino-card-actions .primary-button { flex: 1; text-align: center; }
  .casino-admin-card > button { grid-column: 1 / -1; }
  .casino-card-logo { width: 48px; height: 48px; }
  .casino-stats { flex-wrap: wrap; }
  .casino-materials-title { display: grid; }
  .admin-material-groups { grid-template-columns: 1fr; }
  .filter-row { display: grid; }
  .filter-row select { max-width: none; }
  .admin-header-actions span { display: none; }
  .admin-header-actions { gap: 6px; }
  .admin-exit { padding: 8px 9px; }
  .admin-login-card { padding: 28px 25px; }
  .admin-login-card h1 { font-size: 31px; }

  #activityTable,
  #codesTable,
  #adminsTable { overflow: visible; }
  #activityTable .admin-table,
  #activityTable .admin-table tbody,
  #activityTable .admin-table tr,
  #activityTable .admin-table td,
  #codesTable .admin-table,
  #codesTable .admin-table tbody,
  #codesTable .admin-table tr,
  #codesTable .admin-table td,
  #adminsTable .admin-table,
  #adminsTable .admin-table tbody,
  #adminsTable .admin-table tr,
  #adminsTable .admin-table td { display: block; width: 100%; }
  #activityTable .admin-table thead,
  #codesTable .admin-table thead,
  #adminsTable .admin-table thead { display: none; }
  #activityTable .admin-table tbody,
  #codesTable .admin-table tbody,
  #adminsTable .admin-table tbody { display: grid; gap: 12px; }
  #activityTable .admin-table tr,
  #codesTable .admin-table tr,
  #adminsTable .admin-table tr {
    padding: 14px 15px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    box-shadow: var(--shadow-sm);
  }
  #activityTable .admin-table td,
  #codesTable .admin-table td,
  #adminsTable .admin-table td {
    display: grid;
    grid-template-columns: minmax(88px, 108px) minmax(0, 1fr);
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
    overflow-wrap: anywhere;
  }
  #activityTable .admin-table td:last-child,
  #codesTable .admin-table td:last-child,
  #adminsTable .admin-table td:last-child { border-bottom: 0; }
  #activityTable .admin-table td::before,
  #codesTable .admin-table td::before,
  #adminsTable .admin-table td::before {
    content: attr(data-label);
    color: #587286;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .08em;
    line-height: 1.4;
    text-transform: uppercase;
  }
  #adminsTable .admin-table td:first-child {
    color: var(--blue-deep);
    font-size: 13px;
    font-weight: 800;
  }
  #codesTable .table-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
    white-space: normal;
  }
  #codesTable .mini-button { width: 100%; padding: 8px 5px; }

  #recentActivity,
  #adminUploads,
  #adminLinks { overflow: visible; }
  #recentActivity .admin-table,
  #recentActivity .admin-table tbody,
  #recentActivity .admin-table tr,
  #recentActivity .admin-table td,
  #adminUploads .admin-table,
  #adminUploads .admin-table tbody,
  #adminUploads .admin-table tr,
  #adminUploads .admin-table td,
  #adminLinks .admin-table,
  #adminLinks .admin-table tbody,
  #adminLinks .admin-table tr,
  #adminLinks .admin-table td { display: block; width: 100%; }
  #recentActivity .admin-table thead,
  #adminUploads .admin-table thead,
  #adminLinks .admin-table thead { display: none; }
  #recentActivity .admin-table tbody,
  #adminUploads .admin-table tbody,
  #adminLinks .admin-table tbody { display: grid; gap: 12px; }
  #recentActivity .admin-table tr,
  #adminUploads .admin-table tr,
  #adminLinks .admin-table tr {
    padding: 14px 15px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    box-shadow: var(--shadow-sm);
  }
  #recentActivity .admin-table td,
  #adminUploads .admin-table td,
  #adminLinks .admin-table td {
    display: grid;
    grid-template-columns: minmax(88px, 108px) minmax(0, 1fr);
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
    overflow-wrap: anywhere;
  }
  #recentActivity .admin-table td:last-child,
  #adminUploads .admin-table td:last-child,
  #adminLinks .admin-table td:last-child { border-bottom: 0; }
  #recentActivity .admin-table td::before,
  #adminUploads .admin-table td::before,
  #adminLinks .admin-table td::before {
    content: attr(data-label);
    color: #587286;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .08em;
    line-height: 1.4;
    text-transform: uppercase;
  }
  #adminUploads .admin-table td[data-label="File"],
  #adminLinks .admin-table td[data-label="Link"] {
    color: var(--blue-deep);
    font-size: 13px;
    font-weight: 800;
  }
  #adminUploads .admin-download-button { width: 100%; padding: 9px 12px; }
}