:root {
  color-scheme: dark;
  font-family: Inter, system-ui, sans-serif;
  background: #0f1115;
  color: #f3f5f7;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top, rgba(86, 132, 255, 0.18), transparent 32%),
    linear-gradient(180deg, #101318 0%, #0b0d11 100%);
}

.shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.stack {
  width: min(100%, 760px);
  display: grid;
  gap: 18px;
}

.status-panel,
.incidents-panel {
  display: grid;
  gap: 12px;
  padding: 16px 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(12px);
}

.status-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  color: #9da5b3;
  font-size: 0.9rem;
}

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

.status-card {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
}

.status-label {
  color: #8f97a5;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.status-value {
  margin-top: 4px;
  font-size: 0.98rem;
  font-weight: 700;
}

.metrics-panel {
  display: grid;
  gap: 12px;
}

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

.metric-ranges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.metric-range {
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 999px;
  padding: 5px 9px;
  background: rgba(255,255,255,0.03);
  color: #9da5b3;
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
}

.metric-range:hover,
.metric-range.active {
  border-color: rgba(120, 163, 255, 0.4);
  background: rgba(120, 163, 255, 0.12);
  color: #dce6ff;
}

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

.metric-card {
  position: relative;
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  overflow: hidden;
  transition: background 160ms ease, transform 160ms ease;
}

.metric-card:hover {
  background: rgba(255, 255, 255, 0.045);
  transform: translateY(-1px);
}

.metric-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.metric-label {
  color: #8f97a5;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.metric-value {
  font-weight: 800;
}

.metric-chart {
  width: 100%;
  height: 108px;
  overflow: visible;
}

.metric-baseline {
  fill: none;
  stroke: rgba(255, 255, 255, 0.06);
  stroke-width: 1;
}

.metric-grade {
  fill: #6f7785;
  font-size: 8px;
  font-weight: 700;
}

.metric-line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.22));
}

.metric-hover-target {
  fill: transparent;
  cursor: crosshair;
}

.metric-hover-line {
  fill: none;
  stroke: rgba(255, 255, 255, 0.24);
  stroke-dasharray: 3 3;
  stroke-width: 1;
  pointer-events: none;
}

.metric-hover-dot {
  fill: #101318;
  stroke-width: 2;
  pointer-events: none;
}

.metric-tooltip {
  position: absolute;
  bottom: 30px;
  transform: translateX(-50%);
  z-index: 2;
  white-space: nowrap;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 999px;
  padding: 5px 8px;
  background: rgba(12, 15, 21, 0.92);
  color: #eef3fb;
  font-size: 0.76rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.32);
  pointer-events: none;
}

.metric-meta {
  color: #8f97a5;
  font-size: 0.78rem;
}

.pm2-metric-section {
  display: grid;
  gap: 10px;
}

.pm2-metric-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.pm2-sort-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pm2-metric-charts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.pm2-metric-card {
  min-width: 0;
  display: grid;
  gap: 8px;
  padding: 10px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  transition: background 160ms ease, transform 160ms ease;
}

.pm2-metric-card:hover {
  background: rgba(255, 255, 255, 0.045);
  transform: translateY(-1px);
}

.pm2-metric-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.pm2-metric-name {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.84rem;
  font-weight: 700;
}

.pm2-metric-values {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.pm2-metric-value,
.pm2-metric-status,
.pm2-metric-legend-item {
  border-radius: 999px;
  padding: 3px 7px;
  background: rgba(255,255,255,0.04);
  color: #b9c1cd;
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
}

.pm2-metric-status {
  width: 10px;
  height: 10px;
  padding: 0;
  flex: 0 0 auto;
  box-shadow: 0 0 0 4px rgba(255,255,255,0.04);
}

.pm2-metric-status.online {
  background: #7ce1a9;
}

.pm2-metric-status.other {
  background: #ffd391;
}

.pm2-metric-status.offline {
  background: #ffabab;
}

.pm2-metric-value.cpu,
.pm2-metric-legend-item.cpu {
  color: #bfd1ff;
}

.pm2-metric-value.memory,
.pm2-metric-legend-item.memory {
  color: #b7f0d0;
}

.pm2-metric-value.cpu,
.pm2-metric-value.memory {
  font-size: 0.8rem;
}

.pm2-metric-lines {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.pm2-metric-line-card {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.pm2-metric-label {
  color: #8f97a5;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.pm2-metric-chart {
  width: 100%;
  height: 52px;
}

.pm2-metric-line {
  stroke-width: 2;
  filter: none;
}

.pm2-memory-line {
  opacity: 0.86;
}

.pm2-cpu-line {
  opacity: 0.94;
}

.pm2-metric-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.pm2-list,
.incident-list {
  display: grid;
  gap: 8px;
}

.pm2-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 10px;
  align-items: center;
  padding: 9px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.9rem;
}

.pm2-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pm2-meta {
  color: #9da5b3;
}

.pm2-state {
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.pm2-state.online {
  background: rgba(64, 197, 129, 0.16);
  color: #7ce1a9;
}

.pm2-state.other {
  background: rgba(255, 143, 143, 0.14);
  color: #ffabab;
}

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

.panel-title {
  font-size: 1rem;
  font-weight: 700;
}

.panel-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-button {
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(255,255,255,0.03);
  color: #b9c1cd;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}

.panel-button:hover {
  background: rgba(255,255,255,0.06);
}

.panel-button.active {
  border-color: rgba(120, 163, 255, 0.4);
  background: rgba(120, 163, 255, 0.12);
  color: #dce6ff;
}

.incident-badge {
  min-width: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 89, 89, 0.18);
  color: #ffb3b3;
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
}

.incident-empty {
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255,255,255,0.03);
  color: #9da5b3;
}

.incident-item {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.04);
}

.incident-item.open {
  border-color: rgba(255, 120, 120, 0.18);
}

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

.incident-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.incident-title {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.incident-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  color: #9da5b3;
  font-size: 0.85rem;
}

.incident-summary {
  color: #d8dde6;
  line-height: 1.5;
  font-size: 0.93rem;
}

.incident-pill {
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.incident-pill.high {
  background: rgba(255, 103, 103, 0.16);
  color: #ffb0b0;
}

.incident-pill.medium {
  background: rgba(255, 190, 92, 0.16);
  color: #ffd391;
}

.incident-pill.low {
  background: rgba(120, 163, 255, 0.16);
  color: #aecaff;
}

.incident-status {
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.incident-status.open {
  background: rgba(255, 94, 94, 0.14);
  color: #ffb0b0;
}

.incident-status.resolved {
  background: rgba(64, 197, 129, 0.16);
  color: #7ce1a9;
}

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

.app-link {
  display: grid;
  gap: 6px;
  padding: 12px;
  width: 100%;
  max-width: 300px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  text-decoration: none;
  backdrop-filter: blur(12px);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.app-link:hover {
  transform: translateY(-2px);
  border-color: rgba(120, 163, 255, 0.45);
  background: rgba(255, 255, 255, 0.06);
}

.app-head {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.app-head-text {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.app-icon {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
}

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

.share-icon { background: linear-gradient(135deg, #5f86ff, #86b8ff); }
.trade-icon { background: linear-gradient(135deg, #28a27b, #7ed9ae); }
.prelive-icon { background: linear-gradient(135deg, #f0a02f, #f6d365); }
.live-icon { background: linear-gradient(135deg, #00b8d9, #6c8cff); }
.youtube-icon { background: linear-gradient(135deg, #ff2d55, #ff6b4a); }
.proxy-icon { background: linear-gradient(135deg, #5eead4, #818cf8); }

.app-title {
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.15;
}

.app-hint {
  color: #9da5b3;
  font-size: 0.74rem;
  line-height: 1.2;
}

.app-summary {
  display: grid;
  gap: 4px;
  min-height: 72px;
  padding-top: 0;
}

.app-summary.empty {
  color: #7d8797;
  font-size: 0.82rem;
}

.app-summary-top {
  font-size: 0.76rem;
  font-weight: 700;
  color: #edf2fb;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.app-summary-meta {
  color: #95a2b7;
  font-size: 0.68rem;
}

.app-summary-preview {
  color: #d0d8e4;
  font-size: 0.78rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

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

.app-trading-card {
  display: grid;
  gap: 1px;
  padding: 5px 7px;
  border-radius: 9px;
  background: rgba(255,255,255,0.045);
}

.app-trading-name {
  font-size: 0.72rem;
  font-weight: 700;
  color: #edf2fb;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-trading-card strong {
  font-size: 0.82rem;
  line-height: 1;
}

.app-trading-card strong.positive {
  color: #8ee4b0;
}

.app-trading-card strong.negative {
  color: #ffb0b0;
}

.app-video-list {
  display: grid;
  gap: 5px;
}

.app-video-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 7px;
  align-items: center;
}

.app-video-preview {
  width: 48px;
  height: 28px;
  border-radius: 7px;
  overflow: hidden;
  background: rgba(255,255,255,0.06);
}

.app-video-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.app-video-body {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.app-video-title {
  font-size: 0.76rem;
  color: #e9eef7;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

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

.app-service-card {
  display: grid;
  gap: 2px;
  padding: 6px 8px;
  border-radius: 10px;
  background: rgba(255,255,255,0.045);
}

.app-service-card span {
  color: #95a2b7;
  font-size: 0.68rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-service-card strong {
  font-size: 0.92rem;
  color: #d9eef7;
}

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

.app-counter {
  display: grid;
  gap: 2px;
  padding: 7px 8px;
  border-radius: 10px;
  background: rgba(255,255,255,0.045);
}

.app-counter span {
  color: #95a2b7;
  font-size: 0.67rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.app-counter strong {
  font-size: 0.96rem;
  line-height: 1;
}

.app-counter.good strong {
  color: #8ee4b0;
}

.app-counter.bad strong {
  color: #ffb0b0;
}

.app-counter.warn strong {
  color: #ffd391;
}

.app-pill {
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  color: #c8d3e4;
  font-size: 0.7rem;
}

.app-pill.unread {
  background: rgba(255, 179, 71, 0.14);
  color: #ffd391;
}

.app-actions {
  width: min(100%, 760px);
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
}

.logout-button {
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.04);
  color: #cdd3dc;
  font: inherit;
  cursor: pointer;
}

.gate {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(8, 10, 14, 0.82);
  backdrop-filter: blur(14px);
}

.gate-card {
  width: min(100%, 360px);
  padding: 22px;
  border-radius: 24px;
  background: #151921;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.4);
}

.gate-title { margin: 0 0 8px; font-size: 1.25rem; }
.gate-copy { margin: 0 0 16px; color: #9da5b3; line-height: 1.5; }

.gate-input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: #0f1319;
  color: inherit;
  font: inherit;
}

.gate-input:focus { outline: 1px solid #78a3ff; }

.gate-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.gate-button {
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  background: #78a3ff;
  color: #0b1020;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.gate-status {
  color: #ff8f8f;
  font-size: 0.92rem;
}

.hidden { display: none; }

@media (max-width: 640px) {
  .shell { padding: 16px; }
  .status-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics-header { align-items: flex-start; flex-direction: column; }
  .metric-ranges { justify-content: flex-start; }
  .metric-charts { grid-template-columns: 1fr; }
  .pm2-metric-charts { grid-template-columns: 1fr; }
  .pm2-metric-lines { grid-template-columns: 1fr; }
  .pm2-item { grid-template-columns: minmax(0, 1fr) auto; }
  .apps { grid-template-columns: 1fr; }
  .app-service-grid { grid-template-columns: 1fr 1fr; }
  .app-trading-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
