.login-page,
.admin-page {
  min-height: 100vh;
  padding: 132px 7% 64px;
  background:
    radial-gradient(circle at 20% 12%, rgba(56, 217, 255, 0.17), transparent 28%),
    radial-gradient(circle at 88% 20%, rgba(47, 128, 255, 0.18), transparent 30%);
}

.login-page {
  display: grid;
  place-items: center;
  padding: 34px;
}

.login-card,
.admin-panel {
  width: min(1180px, 100%);
  border: 1px solid var(--line-strong);
  border-radius: 30px;
  background:
    linear-gradient(180deg, rgba(9, 21, 41, 0.96), rgba(4, 11, 23, 0.88)),
    radial-gradient(circle at 20% 12%, rgba(56, 217, 255, 0.18), transparent 28%);
  box-shadow: var(--shadow), var(--glow), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.login-card {
  max-width: 500px;
  padding: 36px;
}

.login-logo {
  margin-bottom: 30px;
}

.login-card h1,
.admin-panel h1,
.application-panel h1,
.admin-panel h2 {
  color: white;
  text-transform: uppercase;
  letter-spacing: -1px;
  line-height: 1;
}

.login-card h1,
.application-panel h1 {
  font-size: clamp(34px, 5vw, 52px);
  margin-bottom: 12px;
}

.admin-panel h1 {
  font-size: clamp(30px, 4vw, 48px);
}

.admin-panel h2 {
  font-size: 28px;
  margin-bottom: 18px;
}

.admin-panel {
  margin: 0 auto;
  padding: 28px;
}

.admin-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 22px;
  padding-bottom: 22px;
  border-bottom: 1px solid rgba(125, 211, 252, 0.15);
}

.application-head {
  align-items: center;
}

.admin-header {
  gap: 18px;
}

.admin-nav {
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.admin-tab {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: #d9e8fb;
  padding: 10px 14px;
  font-weight: 900;
  cursor: pointer;
  transition: 0.22s ease;
}

.admin-tab.active,
.admin-tab:hover {
  color: #001525;
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  border-color: transparent;
}

.admin-tab.danger {
  color: #fecdd3;
  border-color: rgba(251, 113, 133, 0.4);
  background: rgba(251, 113, 133, 0.08);
}

.admin-tab.danger:hover {
  color: white;
  background: rgba(251, 113, 133, 0.3);
}

.admin-form {
  display: grid;
  gap: 16px;
  margin: 24px 0;
}

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

.admin-form label {
  display: grid;
  gap: 8px;
  color: #dff8ff;
  font-size: 13px;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: 0.7px;
}

.admin-form input,
.admin-form textarea,
.admin-form select,
.toolbar select,
.application-card textarea,
.application-card select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(2, 7, 18, 0.72);
  color: white;
  padding: 13px 14px;
  outline: none;
  text-transform: none;
  letter-spacing: 0;
  transition: 0.2s ease;
}

.admin-form textarea,
.application-card textarea {
  resize: vertical;
  line-height: 1.55;
}

.admin-form input:focus,
.admin-form textarea:focus,
.admin-form select:focus,
.toolbar select:focus,
.application-card textarea:focus,
.application-card select:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 4px rgba(56, 217, 255, 0.12);
}

.full-row {
  grid-column: 1 / -1;
}

.check-row {
  display: flex !important;
  align-items: center;
  gap: 10px !important;
}

.check-row input {
  width: auto;
  min-height: auto;
}

.notice {
  min-height: 24px;
  margin-top: 12px;
  color: var(--muted);
  font-weight: 800;
}

.notice-success {
  color: #86efac;
}

.notice-error {
  color: #fda4af;
}

.back-link {
  display: inline-flex;
  margin-top: 16px;
  color: var(--cyan);
  font-weight: 900;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.stat-pill,
.application-card,
.admin-row,
.detail-box {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(125, 211, 252, 0.16);
  border-radius: 18px;
}

.stat-pill {
  padding: 18px;
}

.stat-pill strong {
  display: block;
  color: var(--cyan);
  font-size: 32px;
  line-height: 1;
}

.stat-pill span {
  display: block;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 950;
  margin-top: 8px;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.admin-list {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.application-card,
.admin-row {
  padding: 20px;
}

.badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.badge {
  background: rgba(56, 217, 255, 0.1);
  border-color: var(--line);
  color: #dff8ff;
}

.badge.pending {
  color: #fde68a;
  border-color: rgba(250, 204, 21, 0.35);
  background: rgba(250, 204, 21, 0.08);
}

.badge.interview {
  color: #bfdbfe;
}

.badge.approved {
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.08);
}

.badge.denied {
  color: #fda4af;
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.08);
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.detail-box {
  padding: 13px;
}

.detail-box span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 950;
  margin-bottom: 6px;
}

.detail-box strong {
  color: white;
  word-break: break-word;
}

.backstory {
  margin: 14px 0;
  padding: 14px 16px;
  border-left: 3px solid var(--cyan);
  border-radius: 0 14px 14px 0;
  color: #d9e8fb;
  background: rgba(56, 217, 255, 0.055);
  white-space: pre-wrap;
  line-height: 1.65;
}

.card-actions {
  display: grid;
  grid-template-columns: 190px 1fr auto;
  gap: 10px;
  align-items: start;
  margin-top: 14px;
}

.secure-note {
  margin-top: 12px;
}

.public-form-page {
  padding-top: 132px;
}

.application-panel {
  max-width: 960px;
}

.secure-chip {
  color: #a7f3d0;
  background: rgba(41, 231, 129, 0.1);
  border-color: rgba(41, 231, 129, 0.35);
  white-space: nowrap;
}

@media (max-width: 980px) {
  .stats-grid,
  .grid-form,
  .details-grid,
  .card-actions {
    grid-template-columns: 1fr;
  }

  .admin-header {
    position: fixed;
  }

  .admin-panel-head {
    flex-direction: column;
  }
}

@media (max-width: 780px) {
  .login-page {
    padding: 18px;
  }

  .login-card,
  .admin-panel {
    padding: 24px;
    border-radius: 24px;
  }

  .admin-page,
  .public-form-page {
    padding: 120px 5% 48px;
  }

  .badges {
    justify-content: flex-start;
  }
}

/* Maintenance update: responsive admin layout + dynamic application builder */
.admin-page {
  width: 100%;
  overflow-x: hidden;
}

.admin-panel {
  max-width: min(1220px, calc(100vw - 32px));
  overflow: hidden;
}

.admin-list,
.application-card,
.admin-row,
.details-grid,
.card-actions,
.toolbar,
.fields-builder,
.field-builder-row,
.dynamic-fields {
  min-width: 0;
}

.application-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
}

.application-title-wrap,
.application-title-wrap h3,
.application-title-wrap p,
.detail-box,
.detail-box strong,
.answer-block,
.answer-block p,
.note-list p,
.admin-row,
.audit-row pre {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.answer-block {
  margin: 14px 0;
  padding: 14px 16px;
  border-left: 3px solid var(--cyan);
  border-radius: 0 14px 14px 0;
  color: #d9e8fb;
  background: rgba(56, 217, 255, 0.055);
}

.answer-block span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 950;
}

.answer-block p {
  white-space: pre-wrap;
  line-height: 1.65;
}

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

.toolbar,
.form-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 18px 0;
}

.toolbar select,
.toolbar .btn {
  width: auto;
  max-width: 100%;
}

.builder-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-top: 10px;
}

.builder-header h3 {
  color: white;
  font-size: 20px;
}

.fields-builder {
  display: grid;
  gap: 14px;
}

.field-builder-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(125, 211, 252, 0.16);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.035);
}

.field-cell {
  display: grid;
  gap: 6px;
  color: #dff8ff;
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

.field-cell input,
.field-cell select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(2, 7, 18, 0.72);
  color: white;
  padding: 10px 11px;
  outline: none;
}

.mini-check {
  display: flex !important;
  align-items: center;
  gap: 8px !important;
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(2, 7, 18, 0.72);
  text-transform: none !important;
}

.mini-check input {
  width: auto;
  min-height: auto;
}

.compact-btn {
  min-height: 42px;
  padding: 10px 14px;
  white-space: nowrap;
}

.danger-mini {
  color: #fecdd3;
  border-color: rgba(251, 113, 133, 0.4);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.admin-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
}

.audit-row {
  display: block;
}

.audit-row pre {
  margin-top: 10px;
  max-width: 100%;
  overflow-x: auto;
  color: #9fb4cc;
  white-space: pre-wrap;
}

.discord-gate-card,
.discord-profile {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px;
  border: 1px solid rgba(125, 211, 252, 0.16);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.035);
  margin: 18px 0;
}

.discord-profile img {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  border: 1px solid var(--line);
}

.discord-profile div {
  display: grid;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.discord-profile strong,
.discord-profile span {
  overflow-wrap: anywhere;
}

.discord-profile span {
  color: var(--muted);
  font-size: 13px;
}

.dynamic-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

@media (max-width: 1180px) {
  .field-builder-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .field-builder-row > button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 980px) {
  .application-top,
  .admin-row {
    grid-template-columns: 1fr;
  }

  .badges,
  .row-actions {
    justify-content: flex-start;
  }

  .dynamic-fields {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .admin-panel {
    max-width: calc(100vw - 20px);
    padding: 18px;
    border-radius: 22px;
  }

  .field-builder-row,
  .card-actions {
    grid-template-columns: 1fr;
  }

  .toolbar select,
  .toolbar .btn,
  .discord-gate-card .btn,
  .discord-profile .btn {
    width: 100%;
  }

  .discord-gate-card,
  .discord-profile {
    align-items: flex-start;
    flex-direction: column;
  }
}

.bot-row h3 {
  overflow-wrap: anywhere;
}

.mini-notice {
  padding: 10px 12px;
  margin-top: 10px;
  font-size: 13px;
}

#botForm input[type="password"] {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

/* Dynamic applications and role mapping builder */
.mini-builder-form {
  padding: 18px;
  border: 1px solid rgba(125, 211, 252, 0.16);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.03);
}

.roles-builder .field-builder-row {
  grid-template-columns: repeat(5, minmax(120px, 1fr)) auto;
}

.danger-mini {
  border-color: rgba(251, 113, 133, 0.55) !important;
  color: #fecdd3 !important;
}

.danger-mini:hover {
  background: rgba(251, 113, 133, 0.2) !important;
  color: white !important;
}

@media (max-width: 900px) {
  .roles-builder .field-builder-row {
    grid-template-columns: 1fr;
  }
}

/* Admin maintenance update */
.ticket-card .answer-block p,
.admin-row p,
.audit-row pre {
  overflow-wrap: anywhere;
  word-break: break-word;
}

#webhookLogsList .audit-row pre {
  max-height: 180px;
  overflow: auto;
}

#lockForm input[name="identifier"],
#webhookForm input[type="password"] {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

@media (max-width: 900px) {
  .admin-nav {
    overflow-x: auto;
    justify-content: flex-start;
    width: 100%;
  }
}

/* Account locker massive upgrade */
.lock-toolbar {
  grid-template-columns: 1.7fr repeat(4, minmax(140px, 0.7fr));
  align-items: center;
}

.toolbar input[type="search"] {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(2, 7, 18, 0.72);
  color: white;
  padding: 13px 14px;
  outline: none;
}

.lock-check-form,
#lockForm {
  border: 1px solid rgba(125, 211, 252, 0.16);
  border-radius: 22px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.025);
}

.lock-check-form h3,
#lockForm h3 {
  margin: 0;
  color: #fff;
}

.lock-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
}

.lock-card.lock-disabled {
  opacity: 0.72;
  border-color: rgba(248, 113, 113, 0.24);
}

.lock-card-main h3 {
  overflow-wrap: anywhere;
}

.lock-badges {
  justify-content: flex-start;
  margin: 10px 0 12px;
}

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

.lock-note {
  padding: 12px 14px;
  border-left: 3px solid var(--cyan);
  border-radius: 0 12px 12px 0;
  background: rgba(56, 217, 255, 0.055);
}

.lock-actions {
  min-width: 120px;
}

#lockForm input[name="identifier"],
#lockCheckForm input[name="identifier"] {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

@media (max-width: 1100px) {
  .lock-toolbar {
    grid-template-columns: 1fr 1fr;
  }
  .lock-card,
  .lock-details {
    grid-template-columns: 1fr;
  }
}
.lock-toolbar {
  display: grid;
}
.lock-toolbar select,
.lock-toolbar .btn,
.lock-toolbar input[type="search"] {
  width: 100%;
}

/* Application + ticket review UI v3 */
.toolbar input[type="search"],
.card-actions input {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(2, 7, 18, 0.72);
  color: white;
  padding: 13px 14px;
  outline: none;
}

.application-card,
.ticket-card,
.modern-ticket-card {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}

.details-grid,
.ticket-details-grid {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.card-actions {
  display: grid !important;
  grid-template-columns: minmax(150px, .7fr) minmax(170px, 1fr) minmax(210px, 1.2fr) minmax(260px, 1.5fr) auto;
  align-items: stretch;
}

.card-actions > * {
  min-width: 0;
  width: 100%;
}

.ticket-actions {
  grid-template-columns: minmax(150px, .6fr) minmax(280px, 1.6fr) auto auto !important;
}

.ticket-thread {
  display: grid;
  gap: 12px;
  margin: 16px 0;
  padding: 14px;
  border-radius: 20px;
  border: 1px solid rgba(125, 211, 252, 0.13);
  background: rgba(1, 8, 20, 0.34);
  max-height: 440px;
  overflow: auto;
}

.ticket-bubble {
  max-width: min(760px, 92%);
  padding: 12px 14px;
  border-radius: 17px;
  border: 1px solid rgba(125, 211, 252, 0.14);
  background: rgba(255, 255, 255, 0.045);
}

.ticket-bubble.staff {
  justify-self: end;
  background: rgba(56, 217, 255, 0.1);
  border-color: rgba(56, 217, 255, 0.35);
}

.ticket-bubble strong,
.ticket-bubble p,
.ticket-title-wrap h3,
.ticket-title-wrap p {
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

.ticket-bubble strong {
  display: block;
  color: var(--cyan);
  font-size: 12px;
  margin-bottom: 6px;
}

.ticket-bubble p {
  white-space: pre-wrap;
  line-height: 1.55;
}

.role-builder-row {
  grid-template-columns: repeat(3, minmax(140px, 1fr)) repeat(3, minmax(160px, 1fr)) minmax(100px, .7fr) auto !important;
}

@media (max-width: 1150px) {
  .card-actions,
  .ticket-actions,
  .role-builder-row {
    grid-template-columns: 1fr !important;
  }
}

/* Role automation + review UI v4 */
.card-actions {
  grid-template-columns: minmax(130px, .6fr) minmax(210px, 1fr) minmax(210px, 1fr) minmax(190px, 1fr) minmax(260px, 1.3fr) auto !important;
  gap: 12px;
}

.role-automation-form textarea[name="dmMessage"] {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  line-height: 1.55;
}

.role-automation-card .role-automation-info {
  min-width: 0;
}

.role-automation-card p,
.role-automation-card h3 {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.roles-list .admin-row {
  align-items: flex-start;
}

/* Stronger ticket/admin wrapping fix */
.application-top,
.ticket-top {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: flex-start;
  gap: 16px;
}

.application-title-wrap,
.ticket-title-wrap,
.application-title-wrap h3,
.application-title-wrap p,
.detail-box,
.detail-box strong,
.detail-box span,
.answer-block,
.answer-block p,
.note-list p {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

.ticket-card {
  display: grid;
  gap: 16px;
}

.ticket-card .badges {
  justify-content: flex-end;
  align-content: flex-start;
}

.ticket-details-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)) !important;
  gap: 12px;
}

.ticket-original-message {
  margin-top: 0;
}

.ticket-actions {
  grid-template-columns: minmax(150px, .5fr) minmax(340px, 1.8fr) auto auto !important;
}

@media (max-width: 1250px) {
  .card-actions,
  .ticket-actions {
    grid-template-columns: 1fr !important;
  }
  .application-top,
  .ticket-top {
    grid-template-columns: 1fr;
  }
  .ticket-card .badges {
    justify-content: flex-start;
  }
}
