:root {
  --bg: #111214;
  --bg-2: #1a1b1e;
  --card: #232428;
  --card-2: #2b2d31;
  --border: #34363c;
  --text: #f2f3f5;
  --muted: #a3a6ad;
  --accent: #5865f2;
  --accent-2: #4752c4;
  --green: #23a55a;
  --red: #f23f43;
  --yellow: #f0b232;
  --radius: 12px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: inherit; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* ---------- layout ---------- */
.layout { display: flex; min-height: 100vh; }

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

.brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 1.1rem 1rem;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
}
.brand-icon { width: 32px; height: 32px; border-radius: 50%; }

.nav { display: flex; flex-direction: column; gap: 2px; padding: .75rem .5rem; flex: 1; }
.nav a {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .6rem .75rem;
  border-radius: 8px;
  text-decoration: none;
  color: var(--muted);
  font-weight: 500;
}
.nav a:hover { background: var(--card); color: var(--text); }
.nav a.active { background: var(--accent); color: #fff; }

.user {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .75rem 1rem;
  border-top: 1px solid var(--border);
}
.avatar { width: 34px; height: 34px; border-radius: 50%; }
.user-info { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.user-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.content { flex: 1; padding: 2rem; min-width: 0; max-width: 1200px; }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

/* ---------- cards ---------- */
.grid { display: grid; gap: 1rem; }
.grid-stats { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); margin-bottom: 1.5rem; }
.grid-servers { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
}

.stat-label { color: var(--muted); font-size: .85rem; }
.stat-value { font-size: 1.7rem; font-weight: 700; margin-top: .2rem; }

.server-card { display: flex; flex-direction: column; gap: .75rem; }
.server-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.server-name { font-weight: 700; font-size: 1.05rem; }
.server-players { color: var(--muted); font-size: .9rem; min-height: 1.4em; }
.server-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: auto; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .15rem .6rem;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.badge-on { color: var(--green); background: rgba(35, 165, 90, .15); }
.badge-off { color: var(--red); background: rgba(242, 63, 67, .15); }
.badge-warn { color: var(--yellow); background: rgba(240, 178, 50, .15); }

.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip { background: var(--card-2); border-radius: 6px; padding: .1rem .5rem; font-size: .85rem; }

/* ---------- forms ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  border: 0;
  border-radius: 8px;
  padding: .55rem 1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  background: var(--accent);
  color: #fff;
  transition: background .15s, opacity .15s;
}
.btn:hover { background: var(--accent-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { padding: .35rem .7rem; font-size: .85rem; }
.btn-lg { padding: .8rem 1.4rem; font-size: 1rem; }
.btn-ghost { background: var(--card-2); color: var(--text); }
.btn-ghost:hover { background: var(--border); }
.btn-danger { background: var(--red); }
.btn-danger:hover { background: #d1363a; }
.btn-green { background: var(--green); }
.btn-green:hover { background: #1d8b4c; }
.btn-discord { background: #5865f2; }

.btn-icon {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: .3rem;
  border-radius: 6px;
}
.btn-icon:hover { color: var(--text); background: var(--card); }

label { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); margin-bottom: .3rem; }
.field { margin-bottom: .9rem; }

input, select, textarea {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .6rem .75rem;
  font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.row { display: flex; gap: .5rem; }
.row > * { flex: 1; }
.row > .btn { flex: 0 0 auto; }

.segmented { display: flex; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 3px; gap: 3px; }
.segmented button {
  flex: 1;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  padding: .45rem;
  border-radius: 6px;
  cursor: pointer;
}
.segmented button.active { background: var(--card-2); color: var(--text); }

.suggestions { display: flex; flex-direction: column; gap: 2px; margin-top: .4rem; }
.suggestions button {
  text-align: left;
  background: var(--card-2);
  border: 0;
  color: var(--text);
  font: inherit;
  padding: .5rem .75rem;
  border-radius: 6px;
  cursor: pointer;
}
.suggestions button:hover { background: var(--accent); }

.balance { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; margin-top: 1rem; }
.balance div { background: var(--card-2); border-radius: 8px; padding: .7rem .9rem; }
.balance strong { display: block; font-size: 1.2rem; }
.balance .balance-total { grid-column: 1 / -1; background: rgba(88, 101, 242, .18); }
.balance .balance-total strong { font-size: 1.5rem; }

.console {
  background: #0b0c0e;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .8rem;
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
  overflow: auto;
  margin-top: .75rem;
}

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .6rem .75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
td { font-size: .92rem; }

.vip-toolbar { margin-bottom: 1rem; flex-wrap: wrap; }
.vip-toolbar .segmented { flex: 2 1 320px; }
.vip-toolbar input { flex: 1 1 200px; }

/* ---------- misc ---------- */
.alert { border-radius: 8px; padding: .7rem .9rem; margin: 0 0 1rem; }
.alert-error { background: rgba(242, 63, 67, .15); color: #ff9a9c; }
.alert-info { background: rgba(88, 101, 242, .15); color: #c9cdfb; }

.skeleton {
  background: linear-gradient(90deg, var(--card) 0%, var(--card-2) 50%, var(--card) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: var(--radius);
  min-height: 140px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 50; max-width: calc(100vw - 2rem); }
.toast {
  background: var(--card-2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--green);
  border-radius: 8px;
  padding: .7rem 1rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
  animation: slidein .2s ease-out;
}
.toast.error { border-left-color: var(--red); }
@keyframes slidein { from { transform: translateY(10px); opacity: 0; } }

.dialog {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  width: min(420px, calc(100vw - 2rem));
}
.dialog::backdrop { background: rgba(0, 0, 0, .6); }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.2rem; }

/* ---------- login ---------- */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 1rem;
  background: radial-gradient(circle at 30% 20%, #1f2250 0%, var(--bg) 60%); }
.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  width: min(420px, 100%);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .75rem;
}
.login-logo { font-size: 3rem; }

/* ---------- mobile ---------- */
@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: sticky;
    top: 0;
    z-index: 10;
    flex-direction: row;
    flex-wrap: wrap;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .brand { border-bottom: 0; flex: 1; padding: .7rem 1rem; }
  .user { border-top: 0; padding: .5rem 1rem; }
  .user-info { display: none; }
  .nav { flex-direction: row; width: 100%; order: 3; padding: .25rem .5rem .5rem; overflow-x: auto; }
  .nav a { flex: 1; justify-content: center; padding: .5rem; white-space: nowrap; font-size: .9rem; }
  .content { padding: 1.25rem 1rem; }
  .grid-servers, .grid-2 { grid-template-columns: 1fr; }
  .grid-stats { grid-template-columns: repeat(2, 1fr); }
}
