* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #1a1b1e;
  --bg2: #222327;
  --card: #2a2c31;
  --card-hover: #33363c;
  --border: #3a3d44;
  --text: #e6e7ea;
  --muted: #9aa0aa;
  --accent: #5865f2;
  --accent-hover: #4752f0;
  --green: #23a55a;
  --red: #da373c;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.15rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--text);
}

.brand .logo {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #5865f2, #8b5cf6);
  border-radius: 10px;
  font-size: 1.1rem;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-user img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.nav-user .name { font-size: 0.92rem; }

.owner-link {
  color: var(--muted);
  font-size: .88rem;
  text-decoration: none;
  padding-bottom: 2px;
  border-bottom: 1px solid transparent;
  transition: color .12s ease, border-color .12s ease;
}
.owner-link:hover { color: var(--text); border-color: var(--border); }

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 32px 24px;
}

.hero {
  text-align: center;
  padding: 90px 20px 60px;
}

.hero h1 {
  font-size: 2.6rem;
  margin-bottom: 14px;
}

.hero h1 span {
  background: linear-gradient(135deg, #5865f2, #8b5cf6);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero p {
  color: var(--muted);
  max-width: 520px;
  margin: 0 auto 36px;
  line-height: 1.6;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: none;
  border-radius: 8px;
  padding: 12px 26px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  color: #fff;
  transition: background .15s ease, transform .1s ease;
}

.btn:hover { transform: translateY(-1px); }
.btn-discord { background: #5865f2; }
.btn-discord:hover { background: var(--accent-hover); }
.btn-primary { background: var(--green); }
.btn-primary:hover { background: #1e8f4d; }
.btn-danger { background: var(--red); }
.btn-ghost {
  background: var(--card);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--card-hover); }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none !important; }

h2.section-title {
  font-size: 1.35rem;
  margin: 26px 0 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.guild-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.guild-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  text-decoration: none;
  color: var(--text);
  transition: background .15s ease, transform .15s ease;
}

.guild-card:hover {
  background: var(--card-hover);
  transform: translateY(-2px);
}

.guild-card img,
.guild-card .icon-fallback {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  flex-shrink: 0;
}

.guild-card .icon-fallback {
  display: grid;
  place-items: center;
  background: var(--accent);
  font-weight: 700;
  font-size: 1.2rem;
}

.guild-card .g-name {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.guild-card .g-sub {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 2px;
}

.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: .03em;
}
.badge.owner { background: rgba(88,101,242,.25); color: #aab2ff; }
.badge.configured { background: rgba(35,165,90,.22); color: #57cf87; }
.badge.unconfigured { background: rgba(218,55,60,.2); color: #ff7a7d; }

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 22px;
}

.panel h3 {
  font-size: 1.05rem;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.form-row { margin-bottom: 16px; }

.form-row label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: #cfd3da;
}

.form-row .hint {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 5px;
}

select, input[type="text"] {
  width: 100%;
  background: var(--bg2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 12px;
  font-size: 0.95rem;
  outline: none;
}

select:focus { border-color: var(--accent); }

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

.stat-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  text-align: center;
}

.stat-box .value {
  font-size: 1.7rem;
  font-weight: 800;
  color: #fff;
}

.stat-box .label {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 4px;
}

table.lb {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

table.lb th, table.lb td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

table.lb th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}

table.lb tr:last-child td { border-bottom: none; }
table.lb td.muted, table.lb td.num { color: var(--muted); }
table.lb td.num { text-align: right; font-variant-numeric: tabular-nums; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--green);
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 600;
  opacity: 0;
  transition: all .3s ease;
  z-index: 100;
}

.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.error { background: var(--red); }

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 60px 20px;
}

.back-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 18px;
}
.back-link:hover { color: var(--text); }

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 80px auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

.actions-bar {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

@media (max-width: 600px) {
  .hero h1 { font-size: 1.8rem; }
  .container { padding: 20px 14px; }
}

/* ---------- Owner-Login & Panel ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 34px 32px;
  width: 100%;
  max-width: 380px;
}

.login-error {
  color: #ff7a7d;
  font-size: .86rem;
  margin-top: 12px;
  min-height: 1.2em;
  text-align: center;
}

textarea {
  width: 100%;
  background: var(--bg2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-size: .95rem;
  font-family: inherit;
  resize: vertical;
  outline: none;
}
textarea:focus { border-color: var(--accent); }

.admin-layout {
  display: grid;
  grid-template-columns: 230px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar .brand { padding: 18px 20px; font-size: 1rem; }

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 10px;
  flex: 1;
}

.side-nav button {
  text-align: left;
  background: none;
  border: none;
  color: var(--muted);
  font-size: .93rem;
  font-weight: 500;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .12s ease, color .12s ease;
}

.side-nav button:hover { background: var(--card); color: var(--text); }
.side-nav button.active { background: var(--card); color: #fff; }

.sidebar-footer { padding: 14px; }

.admin-main {
  padding: 28px 34px;
  max-width: 1100px;
}

.result-line {
  margin-top: 14px;
  font-size: .88rem;
  color: #57cf87;
  min-height: 1.3em;
}
.result-line.error { color: #ff7a7d; }

.invite-row td {
  background: var(--bg2);
  font-size: .88rem;
  padding: 10px 12px !important;
}

.invite-link {
  color: #aab2ff;
  font-family: Consolas, monospace;
  user-select: all;
}

.eco-grid {
  display: grid;
  grid-template-columns: 1fr 140px auto;
  gap: 16px;
  align-items: start;
}
.eco-grid .form-row { margin-bottom: 0; }

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  cursor: pointer;
  font-size: .95rem;
}

.switch { position: relative; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }

.switch .slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 999px;
  transition: background .15s ease;
}
.switch .slider::before {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .15s ease;
}
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::before { transform: translateX(20px); }

@media (max-width: 860px) {
  .admin-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; border-right: none; border-bottom: 1px solid var(--border); }
  .side-nav { flex-direction: row; flex-wrap: wrap; }
  .admin-main { padding: 20px 16px; }
  .eco-grid { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr !important; }
}
