:root {
  --bg: #020617;
  --panel: #0e1223;
  --panel-2: #101a2e;
  --line: #334155;
  --text: #f8fafc;
  --muted: #94a3b8;
  --blue: #2563eb;
  --blue-2: #3b82f6;
  --amber: #f97316;
  --green: #22c55e;
  --red: #ef4444;
  --mono: "SF Mono", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(900px 520px at 10% -5%, rgba(37, 99, 235, 0.12), transparent 55%),
    radial-gradient(820px 520px at 96% 8%, rgba(249, 115, 22, 0.08), transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input { font-family: inherit; }

button { cursor: pointer; }

.form-row input,
.search-input {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid #334155;
  border-radius: 12px;
  background: #050a18;
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-row input:focus,
.search-input:focus {
  border-color: var(--blue-2);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}
/* App */
.app-view {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 224px;
  flex: 0 0 224px;
  padding: 22px 14px;
  border-right: 1px solid var(--line);
  background: rgba(7, 12, 26, 0.9);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px 22px;
}

.sidebar-logo__mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #2563eb, #1e40af);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  font-family: var(--mono);
  box-shadow: 0 8px 22px rgba(37, 99, 235, 0.3);
}

.sidebar-logo__text {
  font-weight: 700;
  font-size: 15px;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-nav__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  transition: background 0.2s, color 0.2s;
}

.sidebar-nav__item svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.sidebar-nav__item.is-active,
.sidebar-nav__item:hover {
  background: rgba(37, 99, 235, 0.12);
  color: #93c5fd;
}

.sidebar-logout {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.sidebar-logout:hover {
  border-color: var(--red);
  color: var(--red);
}

.main {
  flex: 1;
  min-width: 0;
  padding: 24px 28px 44px;
}

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

.topbar-title {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0;
}

.topbar-subtitle {
  margin: 5px 0 0;
  font-size: 13px;
  color: var(--muted);
  font-family: var(--mono);
}

.topbar-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: var(--green);
  font-size: 12px;
  font-family: var(--mono);
}

.topbar-status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 10px var(--green);
  animation: blink 1.8s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  padding: 18px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(160deg, rgba(14, 18, 35, 0.95), rgba(10, 16, 32, 0.9));
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120px 80px at 85% 0%, rgba(37, 99, 235, 0.12), transparent);
  pointer-events: none;
}

.stat-card span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.stat-card b {
  font-size: 26px;
  font-family: var(--mono);
}

.stat-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(37, 99, 235, 0.12);
  margin-bottom: 12px;
}

.stat-icon svg {
  width: 18px;
  height: 18px;
}

.stat-card.is-active b { color: var(--green); }
.stat-card.is-expired b { color: var(--amber); }
.stat-card.is-disabled b { color: var(--red); }
.stat-card.is-bound b { color: var(--blue-2); }

.content-grid {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 20px;
  align-items: start;
}

.card {
  background: linear-gradient(160deg, rgba(14, 18, 35, 0.95), rgba(10, 16, 32, 0.9));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: #93c5fd;
}

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

.form-row label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 7px;
}

.search-input {
  width: 220px;
}

.primary-btn,
.secondary-btn {
  width: 100%;
  min-height: 44px;
  border: none;
  border-radius: 11px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.15s;
}

.primary-btn {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  box-shadow: 0 10px 26px rgba(37, 99, 235, 0.28);
}

.secondary-btn {
  margin-top: 10px;
  border: 1px solid var(--line);
  background: rgba(37, 99, 235, 0.1);
  color: #93c5fd;
  font-weight: 600;
}

.primary-btn:active,
.secondary-btn:active { filter: brightness(1.12); }

.form-status {
  min-height: 18px;
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--green);
  word-break: break-all;
  font-family: var(--mono);
}

.table-wrap {
  overflow-x: auto;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.key-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.key-table th,
.key-table td {
  padding: 12px 10px;
  border-bottom: 1px solid #1e293b;
  text-align: left;
  white-space: nowrap;
}

.key-table th {
  color: var(--muted);
  font-weight: 600;
  background: rgba(37, 99, 235, 0.05);
}

.key-table td {
  color: var(--text);
  font-family: var(--mono);
}

.key-table tr:last-child td { border-bottom: none; }

.key-table tr:hover td { background: rgba(37, 99, 235, 0.06); }

.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-family: inherit;
}

.tag-ok { background: rgba(34, 197, 94, 0.14); color: var(--green); }
.tag-disabled { background: rgba(239, 68, 68, 0.14); color: var(--red); }
.tag-expired { background: rgba(249, 115, 22, 0.14); color: var(--amber); }
.tag-none { background: rgba(148, 163, 184, 0.12); color: var(--muted); }

.mini-btn {
  margin-right: 6px;
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(37, 99, 235, 0.08);
  color: #93c5fd;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}

.mini-btn:hover { background: rgba(37, 99, 235, 0.18); }
.mini-btn.danger { background: rgba(239, 68, 68, 0.08); color: var(--red); }
.mini-btn.danger:hover { background: rgba(239, 68, 68, 0.16); }

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 14px;
  font-size: 13px;
  color: var(--muted);
  font-family: var(--mono);
}

.pager button {
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.pager button:disabled { opacity: 0.4; cursor: default; }

.weui-dialog {
  border-radius: 16px;
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.weui-dialog__title { color: #93c5fd; }
.weui-dialog__bd { color: var(--text); }
.weui-dialog__btn { color: var(--text); }
.weui-dialog__btn_primary { color: #93c5fd; }

.weui-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 100;
  width: 170px;
  min-height: 80px;
  margin: 0;
  background: rgba(10, 17, 32, 0.96);
  border: 1px solid var(--line);
  color: var(--text);
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

@media (max-width: 900px) {
  .app-view { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .sidebar-nav { flex: none; flex-direction: row; }
  .sidebar-logout { margin-left: 8px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .content-grid { grid-template-columns: 1fr; }
  .card-head { flex-direction: column; align-items: stretch; }
  .search-input { width: 100%; }
}
