:root {
  color-scheme: dark;
  --bg: #09090f;
  --panel: #131325;
  --border: #2d2e54;
  --text: #f4f4ff;
  --muted: #a3a5cc;
  --primary: #7b61ff;
  --primary-hover: #8f7dff;
  --accent: #42c2ff;
  --danger: #ff6b7a;
  --success: #46d18c;
  --scroll-track: rgba(14, 14, 28, 0.92);
  --scroll-thumb: rgba(123, 97, 255, 0.42);
  --scroll-thumb-hover: rgba(143, 125, 255, 0.65);
}

* {
  box-sizing: border-box;
}

html {
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) var(--scroll-track);
}

html::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

html::-webkit-scrollbar-track {
  background: var(--scroll-track);
  border-radius: 999px;
}

html::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

html::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-thumb-hover);
  background-clip: padding-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  overflow-x: hidden;
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
  background: radial-gradient(circle at top, #171733 0%, var(--bg) 45%);
  color: var(--text);
  font-family: Inter, "Segoe UI", Roboto, sans-serif;
  line-height: 1.45;
}

.container {
  width: min(1040px, 100%);
  max-width: 100%;
  margin: clamp(1rem, 4vw, 3rem) auto;
  padding-left: max(0.75rem, env(safe-area-inset-left));
  padding-right: max(0.75rem, env(safe-area-inset-right));
}

.container.narrow {
  width: min(420px, 100%);
}

.container.dashboard {
  width: min(1200px, 100%);
}

.panel {
  background: rgba(19, 19, 37, 0.88);
  border: 1px solid var(--border);
  border-radius: clamp(14px, 3vw, 18px);
  padding: clamp(1.15rem, 4vw, 2rem);
  backdrop-filter: blur(8px);
  max-width: 100%;
}

.glow {
  box-shadow: 0 0 0 1px rgba(123, 97, 255, 0.3), 0 16px 60px rgba(12, 12, 40, 0.4);
}

h1 {
  margin: 0.4rem 0 0.8rem;
  font-size: clamp(1.5rem, 2.2vw, 2.2rem);
}

.subtitle {
  margin-top: 0;
  color: var(--muted);
}

.badge {
  margin: 0;
  color: var(--accent);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

.form-grid--single {
  grid-template-columns: 1fr;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  color: #d8daf8;
  font-weight: 500;
  font-size: 0.92rem;
}

input,
select,
textarea {
  width: 100%;
  background: #0d0d1c;
  border: 1px solid #2a2a48;
  color: var(--text);
  border-radius: 10px;
  padding: 0.72rem 0.8rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(123, 97, 255, 0.2);
}

textarea {
  resize: vertical;
  min-height: 92px;
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) var(--scroll-track);
}

textarea::-webkit-scrollbar {
  width: 8px;
}

textarea::-webkit-scrollbar-track {
  background: rgba(12, 12, 24, 0.6);
  border-radius: 8px;
}

textarea::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 8px;
}

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

.actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

button,
.link-button {
  background: linear-gradient(135deg, var(--primary), #5046d8);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 0.7rem 1.15rem;
  min-height: 44px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.14s ease, opacity 0.14s ease, background 0.2s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button:hover,
.link-button:hover {
  background: linear-gradient(135deg, var(--primary-hover), #5f54e5);
  transform: translateY(-1px);
}

.link-button--ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.link-button--ghost:hover {
  background: rgba(123, 97, 255, 0.12);
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
}

.status-message {
  margin: 0;
  min-height: 1.2rem;
  color: var(--muted);
}

.status-message.success {
  color: var(--success);
}

.status-message.error {
  color: var(--danger);
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.dashboard-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

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

.toolbar {
  margin: 1.2rem 0;
  display: grid;
  gap: 1rem;
  grid-template-columns: 2fr 1fr;
}

.table-wrap {
  position: relative;
  overflow: auto;
  border: 1px solid #2a2a48;
  border-radius: 12px;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) var(--scroll-track);
  background: rgba(10, 10, 20, 0.35);
}

.table-wrap::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.table-wrap::-webkit-scrollbar-track {
  background: var(--scroll-track);
  border-radius: 8px;
}

.table-wrap::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 8px;
}

.table-wrap::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-thumb-hover);
}

.table-wrap::-webkit-scrollbar-corner {
  background: transparent;
}

/* Tabela admin: layout fixo + colunas proporcionais = cabecalho alinhado ao corpo */
.admin-table {
  width: 100%;
  min-width: 1040px;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
}

.admin-col--id {
  width: 3%;
}
.admin-col--name {
  width: 10%;
}
.admin-col--phone {
  width: 8%;
}
.admin-col--discord {
  width: 9%;
}
.admin-col--nick {
  width: 8%;
}
.admin-col--role {
  width: 5%;
}
.admin-col--opgg {
  width: 6%;
}
.admin-col--long {
  width: 12%;
}
.admin-col--date {
  width: 15%;
}

.admin-table th,
.admin-table td {
  border-bottom: 1px solid #242443;
  padding: 0.55rem 0.6rem;
  vertical-align: top;
  text-align: left;
  font-size: 0.86rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.admin-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: linear-gradient(180deg, #1c1c38 0%, #181831 100%);
  color: #d6d9ff;
  font-weight: 600;
  white-space: normal;
  line-height: 1.25;
  box-shadow: inset 0 -1px 0 #2a2a48;
}

.admin-table td {
  background: rgba(13, 13, 28, 0.35);
}

.admin-table tbody tr:hover td {
  background: rgba(123, 97, 255, 0.06);
}

/* Nao herdar o estilo global de .link-button / button (altura 44px, flex, gradiente) */
.admin-table th button {
  display: inline;
  width: auto;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent !important;
  box-shadow: none;
  color: inherit;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 0.18em;
  text-decoration-color: rgba(123, 97, 255, 0.55);
  transform: none;
}

.admin-table th button:hover {
  color: #fff;
  background: transparent !important;
  transform: none;
  text-decoration-color: var(--accent);
}

.admin-table td a {
  color: #8cc8ff;
  word-break: break-all;
}

.admin-table th:nth-child(1),
.admin-table td:nth-child(1) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.admin-table th:nth-child(1) button {
  display: block;
  width: 100%;
  text-align: right;
}

.admin-table th + th,
.admin-table td + td {
  border-left: 1px solid rgba(36, 36, 67, 0.45);
}

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

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

  .actions {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .actions button {
    width: 100%;
  }

  .table-wrap {
    max-height: min(62vh, 560px);
  }

  th,
  td {
    font-size: 0.82rem;
    padding: 0.5rem 0.55rem;
  }
}

@media (max-width: 640px) {
  h1 {
    font-size: clamp(1.35rem, 5.5vw, 1.75rem);
    line-height: 1.2;
  }

  .subtitle {
    font-size: 0.9rem;
  }

  input,
  select,
  textarea {
    font-size: 16px;
    padding: 0.65rem 0.75rem;
  }

  .dashboard-header {
    flex-direction: column;
    align-items: stretch;
  }

  .dashboard-actions {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .dashboard-actions .link-button,
  .dashboard-actions button {
    width: 100%;
  }

  .admin-user {
    text-align: center;
    padding: 0.25rem 0;
  }

  .table-wrap {
    max-height: min(58vh, 480px);
    border-radius: 10px;
  }

  .admin-table {
    min-width: 960px;
  }
}

@media (max-width: 400px) {
  .container {
    margin-top: 0.75rem;
    margin-bottom: 0.75rem;
  }

  .panel {
    padding: 1rem;
  }

  .admin-table {
    min-width: 900px;
  }
}
