:root {
  --bg-0: #050b17;
  --bg-1: #0a162b;
  --bg-2: #0f203b;
  --surface: #0b1527cc;
  --surface-2: #101f38;
  --surface-3: #0c1830;
  --text: #e8edf7;
  --muted: #9fb0cf;
  --border: #27405f;
  --accent: #36c7f6;
  --ok-bg: #0f5132;
  --ok-tx: #b6f2d8;
  --warn-bg: #5c430f;
  --warn-tx: #ffe8ad;
  --bad-bg: #6e1a1a;
  --bad-tx: #ffd0d0;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background:
    radial-gradient(1100px 520px at 15% -20%, rgba(8, 145, 178, 0.34), transparent 60%),
    radial-gradient(800px 420px at 85% -15%, rgba(37, 99, 235, 0.28), transparent 65%),
    linear-gradient(165deg, var(--bg-0), var(--bg-1) 48%, var(--bg-2));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(90deg, rgba(5, 16, 35, 0.94), rgba(9, 26, 52, 0.9));
  backdrop-filter: blur(8px);
}

.brand h1 {
  margin: 0;
  font-size: 1.9rem;
  letter-spacing: 0.4px;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.live-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 12px;
  color: var(--muted);
  background: rgba(7, 16, 32, 0.7);
}

.live-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulse 1.8s infinite;
}

button {
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #1d3558, #142845);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.18s ease, border-color 0.18s ease, filter 0.18s ease;
}

button:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  filter: brightness(1.08);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.dashboard-grid {
  display: grid;
  gap: 16px;
  padding: 16px;
  grid-template-columns: repeat(12, minmax(0, 1fr));
}

.card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 14px;
  min-height: 180px;
  animation: riseIn 0.42s ease both;
}

.card-health {
  grid-column: span 4;
}

.card-ports {
  grid-column: span 4;
}

.card-opside {
  grid-column: span 4;
}

.card-actions {
  grid-column: span 4;
}

.card-pm2 {
  grid-column: span 8;
}

.card-log {
  grid-column: span 4;
}

.card-docker {
  grid-column: span 12;
}

.card-head {
  margin-bottom: 10px;
}

.card-head h2 {
  margin: 0;
  font-size: 1.5rem;
  line-height: 1.2;
}

.card-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

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

.actions-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
}

.opside-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
}

.opside-resources {
  margin-top: 10px;
  border: 1px solid #2a4668;
  border-radius: 12px;
  background: #081426;
  color: #d2ddf1;
  padding: 10px;
  font-size: 0.82rem;
  line-height: 1.45;
}

.opside-actions {
  margin-top: 10px;
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mem-head {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.82rem;
}

.meter-track {
  margin-top: 6px;
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #09182f;
  border: 1px solid #27405f;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 0;
  transition: width 0.3s ease;
  background: linear-gradient(90deg, #0b7a4e, #14a86c);
}

.meter-fill.warning {
  background: linear-gradient(90deg, #9a6b16, #c78e1e);
}

.meter-fill.critical {
  background: linear-gradient(90deg, #8f2424, #c33737);
}

.metric-warning {
  border-color: #8f6e2a;
}

.metric-critical {
  border-color: #9a3f3f;
}

.opside-sticky-alert {
  border: 1px solid #a46d1d;
  border-left: 4px solid #d99825;
  border-radius: 10px;
  background: #2a1e0f;
  color: #ffe4b0;
  padding: 9px 10px;
  font-size: 0.82rem;
  line-height: 1.35;
}

.opside-sticky-alert > div + div {
  margin-top: 4px;
}

.opside-events {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}

.opside-events li {
  display: grid;
  grid-template-columns: 1.5fr 1.2fr 1.8fr auto;
  gap: 8px;
  align-items: center;
  border: 1px solid #2a4668;
  border-radius: 8px;
  background: #0a1a30;
  padding: 6px 8px;
  font-size: 0.76rem;
}

.metric,
.port,
.quick {
  border: 1px solid #2a4668;
  border-radius: 12px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface-3));
  padding: 10px;
}

.metric .label,
.port .label,
.quick .label {
  color: var(--muted);
  font-size: 0.83rem;
}

.metric .value,
.port .value {
  margin-top: 5px;
  font-size: 1.12rem;
  font-weight: 700;
  line-height: 1.1;
}

.quick strong {
  font-size: 1rem;
}

.quick button {
  margin-top: 9px;
  width: 100%;
}

.table-wrap {
  border: 1px solid #2a4668;
  border-radius: 12px;
  overflow: auto;
  max-height: 460px;
}

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

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #10213b;
}

th,
td {
  border-bottom: 1px solid #213a57;
  padding: 9px;
  text-align: left;
  font-size: 0.88rem;
}

tbody tr:hover {
  background: rgba(66, 153, 225, 0.08);
}

td .mini {
  display: flex;
  gap: 6px;
}

td .mini button {
  font-size: 0.75rem;
  padding: 6px 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.78rem;
  font-weight: 700;
}

.tag.up {
  background: var(--ok-bg);
  color: var(--ok-tx);
}

.tag.down {
  background: var(--bad-bg);
  color: var(--bad-tx);
}

.tag.warn {
  background: var(--warn-bg);
  color: var(--warn-tx);
}

.log-box {
  margin: 0;
  border: 1px solid #2a4668;
  border-radius: 12px;
  background: #081426;
  color: #d2ddf1;
  padding: 10px;
  min-height: 260px;
  max-height: 360px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.78rem;
  line-height: 1.45;
}

.docker-wrap {
  border: 1px solid #2a4668;
  border-radius: 12px;
  overflow: auto;
  padding: 8px;
  min-height: 120px;
  background: #081426;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(1, 8, 19, 0.85);
  backdrop-filter: blur(4px);
}

.overlay.hidden {
  display: none;
}

.login-card {
  width: min(440px, 92vw);
  border: 1px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(180deg, #0f1f3a, #091427);
  box-shadow: var(--shadow);
  padding: 22px;
  animation: popIn 0.32s ease;
}

.login-card h1 {
  margin: 0;
  font-size: 1.7rem;
}

.login-card p {
  color: var(--muted);
}

.login-card label {
  display: block;
  margin-top: 10px;
  margin-bottom: 6px;
  color: #c9d5ef;
}

.login-card input {
  width: 100%;
  border: 1px solid #315079;
  border-radius: 10px;
  background: #081527;
  color: var(--text);
  padding: 10px;
}

.login-card button {
  width: 100%;
  margin-top: 12px;
}

.error {
  color: #ffd2d2;
  min-height: 20px;
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

@media (max-width: 1300px) {
  .card-health,
  .card-ports,
  .card-opside,
  .card-actions,
  .card-log {
    grid-column: span 6;
  }

  .card-pm2,
  .card-docker {
    grid-column: span 12;
  }
}

@media (max-width: 900px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .card-health,
  .card-ports,
  .card-opside,
  .card-actions,
  .card-pm2,
  .card-log,
  .card-docker {
    grid-column: auto;
  }

  .stats-grid,
  .ports-grid,
  .opside-actions {
    grid-template-columns: 1fr;
  }

  .opside-events li {
    grid-template-columns: 1fr;
  }
}
