:root {
  --bg: #0D1117;
  --card: #161B22;
  --card-border: #21262D;
  --text: #E6EDF3;
  --muted: #8B949E;
  --green: #3FB950;
  --yellow: #D29922;
  --red: #F85149;
  --accent: #3FB950;
  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  height: 100%;
}

body {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

.hidden { display: none !important; }

button {
  font-family: inherit;
  cursor: pointer;
}

input, select {
  font-family: inherit;
}

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 320px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 32px 24px;
  text-align: center;
}

.login-pulse {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 6px;
  height: 32px;
  margin-bottom: 16px;
}

.login-pulse span {
  width: 6px;
  background: var(--green);
  border-radius: 3px;
  animation: pulse 1.2s ease-in-out infinite;
}
.login-pulse span:nth-child(1) { height: 30%; animation-delay: 0s; }
.login-pulse span:nth-child(2) { height: 55%; animation-delay: 0.1s; }
.login-pulse span:nth-child(3) { height: 100%; animation-delay: 0.2s; }
.login-pulse span:nth-child(4) { height: 55%; animation-delay: 0.3s; }
.login-pulse span:nth-child(5) { height: 30%; animation-delay: 0.4s; }

@keyframes pulse {
  0%, 100% { transform: scaleY(0.6); opacity: 0.6; }
  50% { transform: scaleY(1); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .login-pulse span { animation: none; }
}

.login-card h1 {
  margin: 0 0 4px;
  font-size: 22px;
  letter-spacing: 0.02em;
}

.login-sub {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 14px;
}

.login-card input {
  width: 100%;
  background: #0D1117;
  border: 1px solid var(--card-border);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 16px;
  margin-bottom: 12px;
}

.login-card button {
  width: 100%;
  background: var(--green);
  color: #04170A;
  border: none;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
}

.login-error {
  color: var(--red);
  font-size: 13px;
  margin: 12px 0 0;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: rgba(13, 17, 23, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--card-border);
}

.topbar-title { display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.topbar-title:active { opacity: 0.6; }
.topbar-title h1 { font-size: 17px; margin: 0; letter-spacing: 0.02em; }

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

.last-update {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  margin-right: 6px;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 18px;
  width: 36px;
  height: 36px;
  border-radius: 8px;
}
.icon-btn:active { background: var(--card-border); }

.push-status {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 16px;
  line-height: 1.5;
}

/* ---------- Status dot ---------- */
.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}
.dot.green { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot.yellow { background: var(--yellow); box-shadow: 0 0 6px var(--yellow); }
.dot.red { background: var(--red); box-shadow: 0 0 6px var(--red); animation: blink 1.4s ease-in-out infinite; }

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
@media (prefers-reduced-motion: reduce) {
  .dot.red { animation: none; }
}

/* ---------- Layout ---------- */
.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 12px;
  max-width: 1100px;
  margin: 0 auto;
}

@media (min-width: 720px) {
  .grid {
    grid-template-columns: 1fr 1fr;
  }
  .card.wide { grid-column: 1 / -1; }
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 14px;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 12px;
}

/* ---------- Server metrics ---------- */
.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.metric {
  background: #0D1117;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 8px 10px;
}

.metric-head {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.metric-head span:last-child {
  font-family: var(--font-mono);
  color: var(--text);
  font-weight: 600;
}

.spark {
  width: 100%;
  height: 34px;
  display: block;
}

/* ---------- Docker container list ---------- */
.container-list, .target-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.row-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #0D1117;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 10px 12px;
}

.row-item .name {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-item .meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.row-item .del-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 16px;
  padding: 2px 4px;
}

.empty-state {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 12px 0;
}

/* ---------- Target row extras ---------- */
.target-row-top {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.target-details {
  display: flex;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.ssl-warn { color: var(--yellow); }
.ssl-crit { color: var(--red); }

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
}
@media (min-width: 600px) {
  .modal { align-items: center; }
}

.modal-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 16px 16px 0 0;
  padding: 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
}
@media (min-width: 600px) {
  .modal-card { border-radius: 16px; }
}

.modal-card h2 {
  margin: 0 0 16px;
  font-size: 17px;
}

.modal-card label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 14px;
}

.modal-card input, .modal-card select {
  display: block;
  width: 100%;
  margin-top: 6px;
  background: #0D1117;
  border: 1px solid var(--card-border);
  color: var(--text);
  padding: 11px 12px;
  border-radius: 10px;
  font-size: 15px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.modal-actions.stacked {
  flex-direction: column;
}
.modal-actions.stacked .btn-primary,
.modal-actions.stacked .btn-secondary {
  flex: none;
}

.btn-primary, .btn-secondary {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  border: none;
  font-size: 14px;
  font-weight: 600;
}
.btn-primary { background: var(--green); color: #04170A; }
.btn-secondary { background: var(--card-border); color: var(--text); }
