:root {
  color-scheme: dark;
  --bg: #090b10;
  --rail: #0f131b;
  --panel: #121722;
  --panel-soft: rgba(18, 23, 34, 0.76);
  --line: #243247;
  --text: #edf5ff;
  --muted: #8f9db2;
  --accent: #46c9ff;
  --accent-2: #8b5cf6;
  --danger: #ff4f75;
  --ok: #31e981;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 10%, rgba(70, 201, 255, 0.16), transparent 28rem),
    radial-gradient(circle at 82% 4%, rgba(139, 92, 246, 0.15), transparent 22rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
}

.rail {
  position: fixed;
  inset: 0 auto 0 0;
  width: 72px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px 10px;
  background: rgba(15, 19, 27, 0.92);
  border-right: 1px solid var(--line);
}

.mark {
  width: 42px;
  height: 42px;
  display: block;
  margin-bottom: 18px;
  object-fit: contain;
}

.nav {
  width: 52px;
  height: 48px;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.nav:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.nav.active { background: rgba(70, 201, 255, 0.16); color: var(--accent); }

.app {
  margin-left: 72px;
  padding: 26px;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}

h1 { margin: 0; font-size: 28px; letter-spacing: 0; }
p { margin: 6px 0 0; color: var(--muted); }

.live {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
}

.live span,
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 20px rgba(49, 233, 129, 0.75);
}

.cards {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.stat,
.panel {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  box-shadow: 0 18px 70px rgba(0,0,0,0.22);
  backdrop-filter: blur(18px);
}

.stat {
  min-height: 112px;
  border-radius: 22px;
  padding: 16px;
}

.stat .material-symbols-rounded,
.panel-title .material-symbols-rounded { color: var(--accent); }
.stat strong { display: block; margin-top: 12px; font-size: 25px; }
.stat small { color: var(--muted); }

.view {
  display: none;
  grid-template-columns: 1.5fr 1fr;
  gap: 14px;
}
.view.active { display: grid; }
#view-users.active { grid-template-columns: minmax(620px, 1.2fr) minmax(420px, 0.8fr); }

.panel {
  border-radius: 24px;
  overflow: hidden;
}
.panel.full { grid-column: 1 / -1; }
.panel.wide { min-height: 420px; }

.panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
}

.panel-title > span {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.panel-title.split {
  justify-content: space-between;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 320px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,0.035);
  color: var(--muted);
}

.search input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(36, 50, 71, 0.72);
  text-align: left;
  font-size: 13px;
}

tr.clickable {
  cursor: pointer;
  transition: background 0.16s ease;
}

tr.clickable:hover,
tr.clickable.selected {
  background: rgba(70, 201, 255, 0.08);
}

.empty-row {
  color: var(--muted);
  text-align: center;
}

th {
  color: var(--muted);
  font-weight: 600;
  background: rgba(255,255,255,0.025);
}

code {
  color: #90e4ff;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
}

.row {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255,255,255,0.035);
}

.row small,
.row em {
  display: block;
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
}

.log-stream {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.log {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(140px, 190px) minmax(220px, 0.8fr);
  gap: 14px;
  align-items: center;
  padding: 13px;
  border-radius: 16px;
  background: rgba(255, 79, 117, 0.09);
  border: 1px solid rgba(255, 79, 117, 0.24);
}

.clickable-log {
  cursor: pointer;
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.clickable-log:hover {
  transform: translateY(-1px);
  background: rgba(255, 79, 117, 0.14);
  border-color: rgba(255, 79, 117, 0.42);
}

.log span,
.log small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.log code {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.badge.ok {
  color: #8df7bc;
  background: rgba(49, 233, 129, 0.12);
  border: 1px solid rgba(49, 233, 129, 0.28);
}

.badge.danger {
  color: #ffd1dc;
  background: rgba(255, 79, 117, 0.14);
  border: 1px solid rgba(255, 79, 117, 0.32);
}

.badge.warn {
  color: #ffe8a3;
  background: rgba(255, 190, 80, 0.13);
  border: 1px solid rgba(255, 190, 80, 0.32);
}

.badge.channel {
  text-transform: lowercase;
  color: #dce8ff;
  background: rgba(70, 201, 255, 0.1);
  border: 1px solid rgba(70, 201, 255, 0.26);
}

.badge.channel.testing {
  color: #ffe6f0;
  background: rgba(255, 79, 117, 0.12);
  border-color: rgba(255, 79, 117, 0.28);
}

.detail-empty {
  padding: 40px 18px;
  color: var(--muted);
  text-align: center;
}

.profile {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.profile strong,
.profile small {
  display: block;
}

.profile small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  word-break: break-all;
}

.notice {
  margin: 14px;
  padding: 12px;
  border-radius: 14px;
}

.notice.danger {
  color: #ffd1dc;
  background: rgba(255, 79, 117, 0.11);
  border: 1px solid rgba(255, 79, 117, 0.26);
}

.actions {
  display: flex;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

select,
.upload-form input,
.upload-form textarea,
button {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 12px;
  background: rgba(255,255,255,0.045);
  color: var(--text);
  font: inherit;
}

button {
  cursor: pointer;
}

button .material-symbols-rounded {
  display: block;
  font-size: 20px;
}

.danger-btn {
  background: rgba(255, 79, 117, 0.14);
  border-color: rgba(255, 79, 117, 0.38);
  color: #ffd1dc;
}

.mini {
  padding: 14px;
  border-bottom: 1px solid rgba(36, 50, 71, 0.55);
}

.mini h3 {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--accent);
}

.mini table td {
  padding: 8px 0;
  border-bottom: 1px solid rgba(36, 50, 71, 0.42);
}

.runtime-settings {
  background: rgba(14, 22, 34, 0.28);
}

.setting-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.setting-select {
  display: grid;
  grid-template-columns: 1fr 140px;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.setting-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.setting-toggle span {
  display: grid;
  gap: 3px;
}

.setting-select span {
  display: grid;
  gap: 3px;
}

.setting-toggle strong {
  font-size: 13px;
}

.setting-toggle small,
.setting-select small {
  color: var(--muted);
}

.slim {
  padding: 12px;
}

.empty {
  padding: 26px;
  color: var(--muted);
  text-align: center;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(8px);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  position: relative;
  width: min(760px, calc(100vw - 48px));
  max-height: min(760px, calc(100vh - 48px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: #111722;
  box-shadow: 0 30px 120px rgba(0, 0, 0, 0.55);
  padding: 22px;
}

.modal h2 {
  margin: 0 0 16px;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 12px;
  font-size: 20px;
}

.modal-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 14px;
  padding: 11px 0;
  border-bottom: 1px solid rgba(36, 50, 71, 0.65);
}

.modal-row span {
  color: var(--muted);
}

.modal-row code {
  white-space: pre-wrap;
  word-break: break-word;
}

.db-actions,
.modal-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.db-actions button {
  width: 38px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
}

.db-path {
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  word-break: break-all;
}

.db-shell {
  display: grid;
  grid-template-columns: 230px 1fr;
  min-height: 560px;
}

.db-tabs {
  padding: 12px;
  border-right: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.12);
}

.db-tab {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  border-radius: 12px;
  text-align: left;
}

.db-tab.active {
  color: var(--accent);
  border-color: rgba(70, 201, 255, 0.38);
  background: rgba(70, 201, 255, 0.11);
}

.db-tab small {
  color: var(--muted);
}

.db-table-wrap {
  overflow: auto;
  max-height: 680px;
}

.db-table th,
.db-table td {
  white-space: nowrap;
}

.db-table td {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-actions {
  width: 80px;
}

.db-modal {
  width: min(980px, calc(100vw - 48px));
}

.db-modal textarea {
  width: 100%;
  min-height: 440px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: rgba(0, 0, 0, 0.24);
  color: var(--text);
  outline: 0;
  font: 13px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.artifact-panel {
  min-height: 520px;
}

.artifact-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 14px;
  padding: 14px;
}

.release-channel {
  display: grid;
  gap: 12px;
}

.release-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.artifact-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(36, 50, 71, 0.72);
  border-radius: 16px;
  background: rgba(255,255,255,0.035);
}

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

.artifact-meta {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 8px 10px;
  align-items: center;
}

.artifact-meta span {
  color: var(--muted);
  font-size: 12px;
}

.artifact-meta code {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-form {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.upload-form label {
  display: grid;
  gap: 7px;
}

.upload-form label > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.upload-form input[type="file"] {
  width: 100%;
}

.upload-form textarea {
  width: 100%;
  min-height: 360px;
  resize: vertical;
  outline: 0;
  line-height: 1.5;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.upload-form button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

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

.modal-actions {
  justify-content: flex-end;
  padding-top: 14px;
}

@media (max-width: 980px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .view.active { grid-template-columns: 1fr; }
  .artifact-grid { grid-template-columns: 1fr; }
  .db-shell { grid-template-columns: 1fr; }
  .db-tabs {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}
