:root {
  --page: #2a2f3c;
  --chrome: #252933;
  --ink: #f5f6fa;
  --muted: #a8adb8;
  --line: rgba(255, 255, 255, 0.1);
  --violet: #9678f0;
  --violet-soft: #b49aff;
  --danger: #ff6b6b;
  --ok: #6ee7a0;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font: 14px/1.45 var(--font);
}
a { color: var(--violet-soft); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }

.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px;
  background: var(--chrome);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 0 20px 20px;
}
.brand span { color: var(--muted); font-weight: 600; font-size: 12px; margin-left: 6px; }
.nav { display: flex; flex-direction: column; flex: 1; }
.nav-item {
  color: var(--muted);
  padding: 9px 20px;
  text-decoration: none;
  border-left: 2px solid transparent;
}
.nav-item:hover { color: var(--ink); text-decoration: none; background: rgba(255,255,255,0.03); }
.nav-item.is-active {
  color: var(--ink);
  border-left-color: var(--violet);
  background: rgba(150,120,240,0.1);
}

.sidebar-foot { margin-top: auto; padding: 16px 20px 0; border-top: 1px solid var(--line); }
.help-btn {
  width: 100%;
  margin-bottom: 14px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 8px;
  cursor: pointer;
  font: inherit;
}
.help-btn:hover { color: var(--ink); border-color: var(--violet); }
.user-card {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 8px 10px;
  align-items: center;
}
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  object-fit: cover; background: #1e222b;
}
.avatar--ph {
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: var(--violet-soft);
}
.user-name { font-weight: 600; }
.user-email, .user-bal { color: var(--muted); font-size: 12px; }
.linkish {
  grid-column: 1 / -1;
  background: none; border: 0; color: var(--muted); cursor: pointer; text-align: left; padding: 0; font: inherit;
}
.linkish:hover { color: var(--danger); }

.main { flex: 1; padding: 28px 36px; max-width: 1100px; }
.main h1 { margin: 0 0 20px; font-size: 22px; font-weight: 700; }
.main h2 { margin: 0; font-size: 15px; font-weight: 600; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 28px;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.stat { padding: 0; background: none; border: 0; }
.stat-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-value { font-size: 28px; font-weight: 700; margin-top: 4px; }

.card {
  background: none;
  border: 0;
  padding: 0;
  margin-bottom: 24px;
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.chips { display: flex; flex-wrap: wrap; gap: 14px; }
.chip {
  display: inline-block;
  padding: 0;
  border: 0;
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}
.chip.is-active { color: var(--ink); font-weight: 600; }
.chip:hover { color: var(--violet-soft); text-decoration: none; }

.chart {
  width: 100%;
  height: auto;
  display: block;
  background: transparent;
  overflow: visible;
}
.chart--area { min-height: 200px; }
.chart-grid { stroke: rgba(255,255,255,0.08); stroke-width: 1; }
.chart-label { fill: #ffffff; font-size: 11px; font-family: inherit; }
.chart-legend { margin-top: 8px; font-size: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 36px; padding: 0 14px;
  border: 1px solid var(--line);
  background: var(--chrome);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  text-decoration: none;
}
.btn:hover { border-color: var(--violet); text-decoration: none; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--violet); border-color: var(--violet); font-weight: 600; }
.btn-primary:hover { filter: brightness(1.05); }

label { display: block; margin-bottom: 12px; color: var(--muted); font-size: 13px; }
input, select, textarea {
  display: block; width: 100%; margin-top: 6px;
  background: var(--chrome); color: var(--ink);
  border: 1px solid var(--line);
  padding: 10px 12px; font: inherit;
}
textarea { resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.check input { width: auto; margin: 0; }

.err {
  background: rgba(255,107,107,0.1);
  border: 1px solid rgba(255,107,107,0.3);
  color: #ffc9c9;
  padding: 10px 12px;
  margin-bottom: 12px;
}
.muted { color: var(--muted); }

.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.auth-card {
  width: 100%; max-width: 380px;
  border: 1px solid var(--line);
  padding: 28px;
}
.auth-card h1 { margin: 0 0 8px; font-size: 22px; }
.qr { display: block; margin: 16px auto; background: #fff; padding: 8px; }
.secret { font-size: 12px; word-break: break-all; }

.split { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 28px; }
.gen-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--line); color: var(--ink);
}
.gen-row input { width: 90px; margin: 0; }
.key-list { list-style: none; padding: 0; margin: 0; }
.key-list li { padding: 6px 0; border-bottom: 1px solid var(--line); }

.pkg-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; margin: 16px 0; }
@media (min-width: 900px) {
  .pkg-grid { grid-template-columns: repeat(4, minmax(0,1fr)); }
}
.pkg {
  border: 1px solid var(--line);
  padding: 16px; position: relative;
}
.pkg--custom label { margin-bottom: 10px; }
.pkg--custom .pkg-credits { font-size: 22px; font-weight: 700; margin: 4px 0 6px; color: var(--ink); }
.pkg-badge {
  position: absolute; top: 12px; right: 12px;
  font-size: 11px; color: var(--ok);
  border: 1px solid rgba(110,231,160,0.35);
  padding: 2px 8px;
}
.pkg h3 { margin: 0 0 8px; }
.pkg-price { font-size: 28px; font-weight: 700; }
.pkg-credits { color: var(--muted); margin: 6px 0 14px; }

.table-wrap { overflow: auto; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 12px 0; flex-wrap: wrap; }
.inline { display: inline-flex; align-items: center; gap: 8px; }
.inline label { margin: 0; }
.inline select { width: auto; margin: 0; }

.modal {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal[hidden] { display: none !important; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.55); }
.modal-dialog {
  position: relative; z-index: 1; width: min(520px, 100%);
  background: var(--page); border: 1px solid var(--line); padding: 20px;
}
.modal-dialog h3 { margin: 0 0 10px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; }
  .stat-grid, .pkg-grid, .split { grid-template-columns: 1fr; }
  .main { padding: 20px 16px; }
}
