:root {
  --bg: #0f1115;
  --bg-elev: #151820;
  --card: #171b22;
  --card-2: #11151b;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(214, 0, 28, 0.26);
  --primary: #d6001c;
  --primary-soft: rgba(214, 0, 28, 0.16);
  --primary-glow: rgba(214, 0, 28, 0.35);
  --text: #f5f7fb;
  --muted: #b5bcc8;
  --success: #16c47f;
  --warn: #ffb020;
  --danger: #ff5c74;
  --radius: 24px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top right, rgba(214, 0, 28, 0.16), transparent 26%),
    radial-gradient(circle at bottom left, rgba(214, 0, 28, 0.12), transparent 26%),
    var(--bg);
  color: var(--text);
}

body { overflow-x: hidden; }

button, input, select {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  background: linear-gradient(180deg, rgba(14, 16, 21, 0.98), rgba(20, 24, 32, 0.98));
  border-right: 1px solid var(--line);
  overflow-y: auto;
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 26px;
}

.brand-logo {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  box-shadow: 0 14px 34px rgba(214, 0, 28, 0.26);
}

.brand-title {
  font-weight: 900;
  font-size: 1.35rem;
  letter-spacing: 0.04em;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 0.94rem;
}

.nav {
  display: grid;
  gap: 10px;
}

.nav-item {
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-weight: 700;
  transition: 0.2s ease;
}

.nav-item:hover,
.nav-item.active {
  background: linear-gradient(180deg, rgba(214, 0, 28, 0.18), rgba(255, 255, 255, 0.03));
  border-color: var(--line-strong);
  box-shadow: inset 0 0 0 1px rgba(214, 0, 28, 0.08);
}

.sidebar-box {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.03);
}

.box-title {
  font-weight: 800;
  margin-bottom: 12px;
}

.mini-stat {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.mini-stat:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.mini-stat strong {
  color: var(--text);
}

.tag-grid,
.inline-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag,
.version-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.06);
  font-size: 0.82rem;
}

.main {
  min-width: 0;
  padding: 22px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

.topbar-left {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.topbar h1 {
  margin: 0 0 6px;
  font-size: clamp(1.5rem, 2vw, 2.1rem);
}

.topbar p {
  margin: 0;
  color: var(--muted);
  max-width: 840px;
}

.topbar-right {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.status-chip {
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--line);
  font-weight: 700;
  white-space: nowrap;
}

.status-chip.success {
  background: rgba(22, 196, 127, 0.15);
  color: #d6fff0;
}

.icon-button {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--line);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#sidebarToggle { display: none; }

.view { display: none; }
.view.active { display: block; }

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--card) 0%, var(--card-2) 100%);
  box-shadow: var(--shadow);
  padding: 20px;
}

.card + .card { margin-top: 18px; }

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.card-head.split { align-items: center; }
.wrap-gap { flex-wrap: wrap; }

.card-head h2 {
  margin: 0 0 6px;
  font-size: 1.25rem;
}

.card-head p {
  margin: 0;
  color: var(--muted);
}

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

.stat-card {
  padding: 18px;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(214, 0, 28, 0.12) 0%, rgba(255, 255, 255, 0.03) 100%);
  border: 1px solid rgba(214, 0, 28, 0.18);
  min-width: 0;
}

.stat-card .label { color: var(--muted); margin-bottom: 8px; }
.stat-card .value {
  font-size: clamp(1.4rem, 2vw, 2rem);
  font-weight: 900;
  margin-bottom: 6px;
  line-height: 1.1;
}
.stat-card .hint { color: #f2c2ca; font-size: 0.92rem; }

.layout-two {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 18px;
  margin-bottom: 18px;
}

.package-layout, .versions-layout { align-items: start; }

.license-list,
.resource-list,
.package-cards,
.module-grid,
.settings-list,
.server-cards,
.config-list,
.version-matrix,
.release-grid {
  display: grid;
  gap: 14px;
}

.license-item,
.resource-item,
.package-card,
.module-card,
.setting-item,
.server-card,
.config-item,
.version-card,
.release-card {
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
  padding: 16px;
}

.license-top,
.server-top,
.server-meta,
.resource-top,
.version-top,
.release-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.license-top strong,
.server-top strong,
.resource-top strong,
.version-top strong,
.release-head strong {
  font-size: 1rem;
}

.small-muted { color: var(--muted); font-size: 0.92rem; }

.progress {
  height: 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
  margin-top: 10px;
}

.progress > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ff6a7c, var(--primary));
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 10px;
  margin-top: 14px;
}

.metric {
  padding: 12px;
  border-radius: 16px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--line);
  min-width: 0;
}

.metric .label,
.metric .value-sm { display: block; }
.metric .label { color: var(--muted); font-size: 0.85rem; margin-bottom: 4px; }
.metric .value-sm { font-weight: 800; }

.table-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.03);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

th, td {
  text-align: left;
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: #ffd6dc;
  font-size: 0.9rem;
  position: sticky;
  top: 0;
  background: #151920;
  z-index: 1;
}

tr:hover td {
  background: rgba(214, 0, 28, 0.06);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 800;
  border: 1px solid rgba(255,255,255,0.08);
  white-space: nowrap;
}

.badge.basic { background: rgba(255,255,255,0.06); }
.badge.pro { background: rgba(255,176,32,0.14); color: #ffe5b3; }
.badge.enterprise { background: rgba(214, 0, 28, 0.18); color: #ffd5db; }
.badge.ok { background: rgba(22,196,127,0.16); color: #d7fff0; }
.badge.warn { background: rgba(255,176,32,0.16); color: #ffeec6; }
.badge.danger { background: rgba(255,92,116,0.16); color: #ffdce2; }
.badge.channel { background: rgba(214, 0, 28, 0.14); color: #ffdce2; }

.action-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 44px;
  padding: 11px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  font-weight: 800;
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.primary-button {
  background: linear-gradient(180deg, rgba(214, 0, 28, 0.96), rgba(178, 0, 23, 0.92));
  box-shadow: 0 16px 32px rgba(214, 0, 28, 0.24);
}

.secondary-button { background: rgba(255,255,255,0.06); }
.ghost-button { background: transparent; }

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.toolbar input,
.toolbar select,
.server-form input,
.server-form select {
  width: 100%;
  min-height: 46px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  padding: 0 14px;
}

.toolbar input { min-width: min(280px, 100%); }

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

.server-card h3,
.package-card h3,
.module-card h3 {
  margin: 0 0 6px;
}

.server-description,
.module-description {
  color: var(--muted);
  margin-bottom: 12px;
}

.server-meta { margin-bottom: 12px; }

.form-card { max-width: 1240px; }

.server-form {
  display: grid;
  gap: 18px;
}

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

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

.server-form label,
.module-select {
  display: grid;
  gap: 8px;
}

.server-form span,
.module-select legend {
  color: #ffd6dc;
  font-weight: 700;
}

.module-select {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.check-item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
}

.check-item input { accent-color: var(--primary); }

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.package-card {
  background: linear-gradient(180deg, rgba(214, 0, 28, 0.14), rgba(255,255,255,0.03));
}

.package-price {
  font-size: 1.8rem;
  font-weight: 900;
  margin-bottom: 4px;
}

.package-list {
  margin: 12px 0 0;
  padding-left: 18px;
  color: var(--muted);
}

.package-list li + li { margin-top: 6px; }

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

.module-card .module-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.module-status {
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(214, 0, 28, 0.18);
  color: #ffd9df;
  font-weight: 800;
  font-size: 0.84rem;
}

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

.setting-item,
.config-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.toggle {
  width: 54px;
  height: 30px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  position: relative;
}

.toggle::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  transition: 0.2s ease;
}

.toggle.active {
  background: rgba(214, 0, 28, 0.45);
}

.toggle.active::after {
  left: 28px;
}

.version-card {
  background: linear-gradient(180deg, rgba(214, 0, 28, 0.11), rgba(255,255,255,0.02));
}

.version-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.version-pill {
  background: rgba(255,255,255,0.05);
}

.version-pill strong {
  color: #ffd8de;
}

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

.release-card {
  background: linear-gradient(180deg, rgba(214, 0, 28, 0.11), rgba(255,255,255,0.02));
}

.release-card p {
  color: var(--muted);
  margin: 8px 0 12px;
  line-height: 1.45;
}

.release-meta {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.92rem;
}

.release-file {
  color: #ffdbe1;
}

dialog {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(20,20,27,0.98), rgba(30,30,37,0.98));
  color: var(--text);
  width: min(760px, calc(100vw - 24px));
  padding: 0;
  box-shadow: 0 30px 80px rgba(0,0,0,0.45);
}

dialog::backdrop {
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.dialog-head h3 { margin: 0; }

.dialog-body {
  padding: 20px;
}

.dialog-list {
  display: grid;
  gap: 12px;
}

.dialog-item {
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
}

.dialog-item .action-group { margin-top: 10px; }

@media (max-width: 1240px) {
  .stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .module-grid,
  .release-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1040px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: min(88vw, 340px);
    transform: translateX(-104%);
    transition: transform 0.25s ease;
    box-shadow: 0 24px 60px rgba(0,0,0,0.45);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  #sidebarToggle {
    display: inline-flex;
  }

  .main {
    padding: 16px;
  }

  .layout-two,
  .server-cards,
  .settings-list,
  .module-grid,
  .release-grid,
  .stats-grid,
  .form-grid,
  .check-grid,
  .metric-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-right {
    width: 100%;
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  .main {
    padding: 12px;
  }

  .card {
    padding: 16px;
    border-radius: 20px;
  }

  .layout-two,
  .server-cards,
  .settings-list,
  .module-grid,
  .release-grid,
  .stats-grid,
  .form-grid,
  .form-grid-two,
  .check-grid,
  .metric-row {
    grid-template-columns: 1fr;
  }

  .topbar-left {
    gap: 10px;
  }

  .topbar h1 {
    font-size: 1.35rem;
  }

  .toolbar {
    width: 100%;
  }

  .toolbar input,
  .toolbar select,
  .action-group > * {
    width: 100%;
  }

  .card-head,
  .card-head.split,
  .version-top,
  .release-head,
  .setting-item,
  .config-item,
  .server-top,
  .license-top,
  .resource-top {
    flex-direction: column;
    align-items: flex-start;
  }

  .status-chip {
    width: 100%;
    justify-content: center;
    display: inline-flex;
  }

  .tag, .version-pill, .badge {
    white-space: normal;
  }

  table {
    min-width: 760px;
  }

  th, td {
    padding: 12px 10px;
  }

  dialog {
    width: calc(100vw - 16px);
  }

  .dialog-body,
  .dialog-head {
    padding: 16px;
  }
}
