:root {
  color-scheme: dark;
  --bg: #080a0f;
  --bg-2: #0c0f16;
  --panel: rgba(18, 22, 31, .92);
  --panel-2: #151923;
  --border: rgba(255,255,255,.08);
  --border-strong: rgba(255,255,255,.14);
  --text: #f7f8fb;
  --muted: #929bad;
  --muted-2: #697386;
  --red: #ff3131;
  --red-2: #d9162d;
  --red-soft: rgba(255,49,49,.13);
  --green: #45d894;
  --yellow: #ffc857;
  --blue: #6da8ff;
  --radius: 22px;
  --shadow: 0 24px 80px rgba(0,0,0,.38);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: Arial, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 85% -10%, rgba(255,49,49,.10), transparent 30%),
    radial-gradient(circle at -10% 100%, rgba(72,40,180,.08), transparent 35%),
    var(--bg);
}
button, input, textarea, select { font: inherit; }
button { border: 0; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

.ambient { position: fixed; width: 500px; height: 500px; border-radius: 50%; filter: blur(150px); opacity: .23; z-index: -1; pointer-events: none; }
.ambient-one { background: #a10015; top: -330px; right: -100px; }
.ambient-two { background: #280067; bottom: -360px; left: -180px; }

.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(560px, 100%);
  background: linear-gradient(145deg, rgba(24,28,39,.98), rgba(12,15,22,.98));
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  border-radius: 28px;
  padding: 42px;
  text-align: center;
}
.brand-mark { width: 64px; height: 64px; margin: 0 auto 18px; display: grid; place-items: center; border-radius: 20px; background: linear-gradient(145deg, var(--red), var(--red-2)); box-shadow: 0 14px 40px rgba(255,49,49,.28); font-size: 34px; font-weight: 900; }
.brand-mark.small { width: 45px; height: 45px; margin: 0; border-radius: 14px; font-size: 23px; }
.eyebrow { color: var(--red); font-size: 12px; font-weight: 900; letter-spacing: 1.5px; margin: 0 0 9px; }
h1,h2,h3,p { margin-top: 0; }
.login-card h1 { font-size: clamp(28px, 5vw, 42px); margin-bottom: 12px; }
.login-card > p:not(.eyebrow) { color: var(--muted); line-height: 1.7; margin-bottom: 26px; }
.login-card label { display: block; text-align: right; font-weight: 700; margin-bottom: 8px; }
.login-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.login-card small { display: block; color: var(--muted-2); margin-top: 18px; }
.form-message { min-height: 22px; color: #ff7b87; margin-top: 12px; }

input, textarea, select {
  width: 100%;
  border: 1px solid var(--border);
  background: #0d1119;
  color: var(--text);
  border-radius: 13px;
  padding: 12px 14px;
  transition: border-color .2s, box-shadow .2s;
}
textarea { resize: vertical; min-height: 88px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: rgba(255,49,49,.7); box-shadow: 0 0 0 3px rgba(255,49,49,.11); }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 10px 16px; border-radius: 12px; cursor: pointer; font-weight: 800; transition: transform .18s, opacity .18s, background .18s; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: .55; transform: none; }
.button.primary { background: linear-gradient(135deg, var(--red), var(--red-2)); color: white; box-shadow: 0 10px 28px rgba(255,49,49,.18); }
.button.secondary { background: #202632; color: white; border: 1px solid var(--border); }
.button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.button.text { background: transparent; color: var(--red); min-height: auto; padding: 5px; }
.button.icon { width: 44px; padding: 0; font-size: 23px; background: #1a1f29; border: 1px solid var(--border); }
.button.small { min-height: 34px; padding: 7px 11px; font-size: 12px; }
.button.danger { background: rgba(255,49,49,.12); color: #ff7d88; border: 1px solid rgba(255,49,49,.24); }
.button.full { width: 100%; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 270px 1fr; }
.sidebar {
  position: fixed;
  inset: 0 0 0 auto;
  width: 270px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 24px 18px;
  background: rgba(10,12,18,.94);
  border-left: 1px solid var(--border);
  backdrop-filter: blur(18px);
  z-index: 10;
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 24px; border-bottom: 1px solid var(--border); }
.sidebar-brand strong, .sidebar-brand span { display: block; }
.sidebar-brand span { color: var(--muted); font-size: 12px; margin-top: 3px; }
.nav-list { display: grid; gap: 8px; margin-top: 24px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-radius: 13px; background: transparent; color: var(--muted); cursor: pointer; text-align: right; font-weight: 800; }
.nav-item span { width: 25px; text-align: center; }
.nav-item:hover { background: rgba(255,255,255,.04); color: white; }
.nav-item.active { background: var(--red-soft); color: white; border: 1px solid rgba(255,49,49,.18); }
.sidebar-footer { margin-top: auto; display: grid; gap: 12px; }
.connection-card, .server-chip { display: flex; align-items: center; gap: 10px; }
.connection-card { padding: 12px; border-radius: 14px; background: #121720; border: 1px solid var(--border); }
.connection-card strong, .connection-card span { display: block; }
.connection-card span { color: var(--muted); font-size: 12px; margin-top: 3px; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px rgba(69,216,148,.10); }

.main-content { grid-column: 2; width: 100%; min-width: 0; padding: 26px 34px 60px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 24px; margin-bottom: 28px; }
.topbar h1 { margin-bottom: 7px; font-size: 30px; }
.topbar p:last-child { color: var(--muted); margin-bottom: 0; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.server-chip { min-width: 210px; padding: 8px 12px; border-radius: 15px; background: #141923; border: 1px solid var(--border); }
.server-chip strong, .server-chip span { display: block; }
.server-chip span { color: var(--muted); font-size: 12px; margin-top: 3px; }
.avatar { width: 39px; height: 39px; border-radius: 12px; object-fit: cover; }
.avatar.fallback { display: grid; place-items: center; background: var(--red); font-weight: 900; }

.page-section { display: none; animation: fade .24s ease; }
.page-section.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.hero-card { min-height: 260px; display: flex; justify-content: space-between; align-items: center; gap: 30px; padding: 38px; border-radius: 26px; border: 1px solid var(--border); background: linear-gradient(130deg, rgba(27,31,43,.96), rgba(12,15,22,.96)); box-shadow: var(--shadow); overflow: hidden; position: relative; }
.hero-card::after { content: ""; position: absolute; width: 330px; height: 330px; border-radius: 50%; background: rgba(255,49,49,.09); filter: blur(40px); left: -100px; top: -130px; }
.hero-card > div { position: relative; z-index: 1; }
.hero-card h2 { max-width: 680px; font-size: clamp(28px, 4vw, 45px); margin-bottom: 14px; }
.hero-card p:not(.eyebrow) { color: var(--muted); max-width: 720px; line-height: 1.7; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 24px; color: var(--muted); margin-top: 24px; }
.hero-meta b { color: white; font-size: 22px; margin-left: 5px; }
.bot-orb { flex: 0 0 160px; width: 160px; height: 160px; display: grid; place-items: center; position: relative; }
.orb-ring { position: absolute; inset: 0; border-radius: 50%; border: 1px solid rgba(255,49,49,.4); box-shadow: inset 0 0 40px rgba(255,49,49,.12), 0 0 60px rgba(255,49,49,.10); }
.bot-avatar { width: 112px; height: 112px; border-radius: 50%; object-fit: cover; }
.bot-avatar.fallback { display: grid; place-items: center; background: linear-gradient(145deg, #242a38, #10131a); font-size: 42px; font-weight: 900; }
.bot-orb > span { position: absolute; bottom: 4px; font-size: 10px; letter-spacing: 1px; font-weight: 900; color: var(--green); background: #10151c; border: 1px solid rgba(69,216,148,.25); border-radius: 100px; padding: 5px 10px; }

.stats-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; margin: 18px 0; }
.stat-card { min-height: 135px; display: flex; gap: 13px; padding: 20px; border-radius: 18px; background: var(--panel); border: 1px solid var(--border); }
.stat-card.accent { background: linear-gradient(145deg, rgba(255,49,49,.17), rgba(20,24,33,.95)); border-color: rgba(255,49,49,.22); }
.stat-icon { width: 38px; height: 38px; flex: 0 0 38px; border-radius: 12px; display: grid; place-items: center; background: rgba(255,255,255,.05); color: var(--red); font-weight: 900; }
.stat-card small { color: var(--muted); }
.stat-card strong { display: block; font-size: 25px; margin: 9px 0 6px; }
.stat-card p { margin: 0; color: var(--muted-2); font-size: 12px; }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: 0 16px 45px rgba(0,0,0,.16); }
.panel-heading, .section-heading, .subheading { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.panel-heading { margin-bottom: 18px; }
.panel-heading h2, .section-heading h2 { margin-bottom: 0; }
.panel-badge { min-width: 36px; height: 30px; display: grid; place-items: center; padding: 0 10px; border-radius: 999px; color: var(--red); background: var(--red-soft); border: 1px solid rgba(255,49,49,.17); font-size: 12px; font-weight: 900; }
.section-heading { margin-bottom: 20px; }
.section-heading p:last-child { color: var(--muted); margin: 8px 0 0; }
.two-column { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.health-list { display: grid; gap: 0; }
.health-list > div { display: flex; justify-content: space-between; gap: 20px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.health-list > div:last-child { border-bottom: 0; }
.health-list span { color: var(--muted); }
.health-list b.good { color: var(--green); }
.health-list b.warn { color: var(--yellow); }
.quick-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }

.editor-layout { display: grid; grid-template-columns: minmax(330px, 430px) minmax(0, 1fr); gap: 18px; align-items: start; }
.sticky-panel { position: sticky; top: 22px; }
.content-stack { display: grid; gap: 18px; min-width: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.form-grid label { display: grid; gap: 7px; color: #dce0e8; font-size: 13px; font-weight: 800; }
.form-grid .wide { grid-column: 1 / -1; }
.check-row { display: flex !important; align-items: center; grid-template-columns: auto 1fr; }
.check-row input { width: 18px; height: 18px; }
.items-editor { border-top: 1px solid var(--border); padding-top: 15px; }
.subheading strong, .subheading small { display: block; }
.subheading small { color: var(--muted); margin-top: 4px; }
#item-rows { display: grid; gap: 9px; margin-top: 12px; }
.item-row { display: grid; grid-template-columns: 1fr .8fr 90px 36px; gap: 8px; }
.item-row .remove-item { width: 36px; height: 40px; border-radius: 10px; cursor: pointer; background: rgba(255,49,49,.12); color: #ff7885; }

.package-admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.package-card { display: flex; flex-direction: column; min-height: 220px; padding: 18px; border-radius: 17px; background: #11161f; border: 1px solid var(--border); position: relative; overflow: hidden; }
.package-card.disabled { opacity: .56; }
.package-card::before { content: ""; position: absolute; width: 120px; height: 120px; border-radius: 50%; left: -55px; top: -55px; background: rgba(255,49,49,.08); }
.package-card h3 { margin: 8px 0; font-size: 20px; }
.package-card p { color: var(--muted); line-height: 1.55; flex: 1; }
.package-card .package-price { font-size: 24px; font-weight: 900; color: white; }
.package-card .package-rewards { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.chip { display: inline-flex; align-items: center; min-height: 27px; padding: 4px 9px; border-radius: 999px; background: rgba(255,255,255,.05); color: #cbd2de; font-size: 11px; border: 1px solid var(--border); }
.chip.red { background: var(--red-soft); color: #ff8d96; border-color: rgba(255,49,49,.18); }
.package-actions, .management-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }

.management-list { display: grid; gap: 10px; }
.management-item { border-radius: 16px; background: #11161f; border: 1px solid var(--border); padding: 16px; }
.management-item-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.management-item h3 { margin-bottom: 7px; }
.management-item p { color: var(--muted); margin-bottom: 11px; line-height: 1.55; }
.management-meta { display: flex; flex-wrap: wrap; gap: 12px; color: var(--muted-2); font-size: 12px; }
.status { display: inline-flex; align-items: center; min-height: 27px; padding: 4px 9px; border-radius: 999px; font-size: 11px; font-weight: 900; }
.status.active, .status.completed, .status.delivered { background: rgba(69,216,148,.12); color: var(--green); }
.status.pending, .status.created, .status.approved, .status.partial { background: rgba(255,200,87,.11); color: var(--yellow); }
.status.failed, .status.cancelled { background: rgba(255,49,49,.12); color: #ff7d88; }
.status.ended, .status.closed { background: rgba(255,255,255,.06); color: var(--muted); }

.table-scroll { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { padding: 13px 10px; text-align: right; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; }
td { font-size: 13px; }
.user-cell { display: flex; align-items: center; gap: 9px; }
.user-cell img, .mini-avatar { width: 34px; height: 34px; border-radius: 10px; object-fit: cover; background: #242b38; }
.user-cell strong, .user-cell span { display: block; }
.user-cell span { color: var(--muted); font-size: 11px; margin-top: 2px; }
.empty-state { padding: 28px; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: 14px; }
.community-grid { grid-template-columns: minmax(0, 1.5fr) minmax(320px, .7fr); }
.compact .management-item { padding: 13px; }

.toast { position: fixed; left: 24px; bottom: 24px; z-index: 100; max-width: 420px; transform: translateY(20px); opacity: 0; pointer-events: none; background: #18211e; color: #dff9ec; border: 1px solid rgba(69,216,148,.22); box-shadow: var(--shadow); border-radius: 14px; padding: 13px 17px; transition: .22s; }
.toast.visible { transform: none; opacity: 1; }
.toast.error { background: #241417; color: #ffdfe3; border-color: rgba(255,49,49,.25); }

@media (max-width: 1500px) {
  .stats-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
}
@media (max-width: 1100px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: auto; height: auto; padding: 14px; }
  .sidebar-brand, .sidebar-footer { display: none; }
  .nav-list { margin: 0; grid-template-columns: repeat(5, 1fr); overflow-x: auto; }
  .nav-item { white-space: nowrap; justify-content: center; }
  .main-content { padding: 20px; }
  .editor-layout, .two-column, .community-grid { grid-template-columns: 1fr; }
  .sticky-panel { position: static; }
}
@media (max-width: 760px) {
  .topbar { align-items: flex-start; }
  .topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
  .server-chip { display: none; }
  .hero-card { padding: 25px; }
  .bot-orb { display: none; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .package-admin-grid { grid-template-columns: 1fr; }
  .quick-actions { grid-template-columns: 1fr; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .item-row { grid-template-columns: 1fr 80px 35px; }
  .item-row input:nth-child(2) { display: none; }
}
@media (max-width: 520px) {
  .login-card { padding: 28px 20px; }
  .login-row { grid-template-columns: 1fr; }
  .main-content { padding: 15px; }
  .topbar { display: block; }
  .topbar-actions { margin-top: 14px; justify-content: flex-start; }
  .stats-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid > * { grid-column: 1 !important; }
  .nav-list { grid-template-columns: repeat(5, max-content); }
}
