*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  min-height: 100%; background: #0d1117; color: #e6edf3;
  font-family: 'Segoe UI', system-ui, sans-serif;
}
body {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 100vh; padding: 40px 20px;
}
nav { position: fixed; top: 24px; left: 32px; }
nav a {
  display: inline-flex; align-items: center; gap: 7px;
  color: #22d3ee; text-decoration: none; font-size: 0.78rem; font-weight: 600;
  letter-spacing: 1px; text-transform: uppercase;
  background: #0a1e20; border: 1px solid #0891b244; border-radius: 8px; padding: 6px 14px;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
nav a:hover { background: #0f2e32; border-color: #22d3ee; transform: translateX(-2px); }

.card {
  background: #161b22;
  border: 1px solid #21262d;
  border-radius: 20px;
  padding: 48px 52px;
  width: 100%; max-width: 1200px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5);
}
.card-header { text-align: center; margin-bottom: 36px; }
.card-header .icon { font-size: 2.8rem; display: block; margin-bottom: 14px; }
.card-header h2 { font-size: 1.5rem; color: #e6edf3; letter-spacing: 1px; margin-bottom: 6px; }
.card-header p { font-size: 0.82rem; color: #8b949e; }

.section-title {
  font-size: 0.78rem; color: #22d3ee; font-weight: 700;
  letter-spacing: 1.5px; text-transform: uppercase;
  border-bottom: 1px solid #21262d; padding-bottom: 8px; margin-bottom: 20px;
}

.group-sep { border: none; border-top: 1px solid #21262d; margin: 0 0 20px; }
.row { display: flex; gap: 16px; margin-bottom: 18px; }
.field { flex: 1; }
.field-port { flex: 0 0 110px; }
label {
  display: block; font-size: 0.75rem; color: #8b949e;
  letter-spacing: 1px; text-transform: uppercase; margin-bottom: 8px;
}
input, select {
  width: 100%; background: #0d1117;
  border: 1px solid #30363d; border-radius: 10px;
  color: #e6edf3; padding: 11px 16px;
  font-size: 0.92rem; outline: none; font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, select:focus {
  border-color: #22d3ee;
  box-shadow: 0 0 0 3px rgba(34,211,238,0.08);
}
@keyframes field-blink {
  0%, 100% { border-color: #30363d; box-shadow: none; }
  50% { border-color: #ff6b6b; box-shadow: 0 0 0 3px rgba(255,107,107,0.3); }
}
input.blink { animation: field-blink 0.4s ease-in-out 3; }

.auth-block .field { margin-bottom: 18px; }
.auth-block .field:last-child { margin-bottom: 0; }
.auth-block { margin-bottom: 20px; }

.connect-btn {
  width: 100%; padding: 13px;
  background: linear-gradient(135deg, #0a2e2e, #0e3d3d);
  color: #22d3ee; border: 1px solid #0891b2;
  border-radius: 10px; font-size: 1rem; font-weight: 700;
  letter-spacing: 1px; cursor: pointer;
  transition: filter 0.2s, transform 0.15s;
  margin-bottom: 20px;
}
.connect-btn:hover { filter: brightness(1.2); transform: translateY(-1px); }
.connect-btn:active { transform: scale(0.98); }
.connect-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.action-btn {
  width: 100%; padding: 12px;
  background: #161b22; color: #c084fc;
  border: 1px solid #9333ea; border-radius: 10px;
  font-size: 0.95rem; font-weight: 700; letter-spacing: 1px;
  cursor: pointer; transition: filter 0.2s, transform 0.15s;
  margin-bottom: 20px;
}
.action-btn:hover { filter: brightness(1.3); transform: translateY(-1px); }
.action-btn:active { transform: scale(0.98); }
.action-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
@keyframes btn-dots {
  0%   { content: ''; }
  25%  { content: '.'; }
  50%  { content: '..'; }
  75%, 100% { content: '...'; }
}
.action-btn:disabled:not(.pd-set)::after,
.action-btn.pd-set.busy::after {
  content: '';
  display: inline-block;
  width: 1.4em; text-align: left;
  animation: btn-dots 1.1s steps(1) infinite;
}

.ping-row { display: flex; gap: 16px; align-items: center; margin-bottom: 20px; }
.meter-info { margin: -8px 0 20px; font-size: 0.82rem; color: #8b949e; min-height: 1em; }
.meter-info b { color: #e6edf3; font-weight: 600; }
.push-dest-row { display: flex; gap: 16px; align-items: center; margin-bottom: 14px; }
.push-dest-row .pd-label { flex: 0 0 240px; margin-bottom: 0; }
.push-dest-row .pd-name { display: block; }
.push-dest-row .pd-obis { display: block; text-transform: none; font-size: 0.7rem; opacity: 0.7; margin-top: 3px; }
.push-dest-row input { flex: 1; }
.push-dest-row .pd-set { flex: 0 0 120px; margin-bottom: 0; }
.ping-row .action-btn { flex: 1; margin-bottom: 0; }
.conn-stat { flex: none; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.conn-tag { font-size: 0.62rem; color: #8b949e; letter-spacing: 1px; text-transform: uppercase; }
.ping-status { flex: none; width: 56px; text-align: center; font-size: 1.3rem; font-weight: 700; color: #8b949e; }
.ping-status.ok { color: #3fb950; }
.ping-status.err { color: #ff6b6b; }

.output-wrap {
  position: relative;
  width: 100%; max-width: 1200px; margin-top: 28px;
}
.output-label {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.75rem; color: #8b949e;
  letter-spacing: 1px; text-transform: uppercase; margin-bottom: 8px;
}
.clear-btn {
  background: none; border: 1px solid #30363d; border-radius: 6px;
  color: #8b949e; font-size: 0.72rem; padding: 3px 10px; cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.clear-btn:hover { border-color: #22d3ee; color: #22d3ee; }

#output {
  width: 100%; min-height: 120px; max-height: 400px;
  background: #0d1117; border: 1px solid #30363d; border-radius: 10px;
  color: #3fb950; padding: 14px 16px;
  font-size: 0.82rem; font-family: 'Consolas', 'Courier New', monospace;
  overflow: auto; white-space: pre;
}
.line-ok  { color: #3fb950; }
.line-err { color: #ff6b6b; }
.line-info { color: #22d3ee; }

/* Push Setup destinations popup */
.overlay {
  display: none; position: fixed; inset: 0; z-index: 9000;
  background: rgba(0,0,0,0.8); backdrop-filter: blur(4px);
  align-items: center; justify-content: center; padding: 20px;
}
.overlay.show { display: flex; }
.modal {
  background: #161b22; border: 1px solid #30363d; border-radius: 16px;
  padding: 28px 30px; width: 100%; max-width: 640px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
}
#value-overlay .modal { max-width: 1280px; }
#push-overlay.objects-mode .modal { max-width: 95vw; }
#push-overlay.objects-mode .modal-list { overflow: auto; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.modal-header h3 {
  font-size: 1.1rem; color: #c084fc; letter-spacing: 1px;
}
.modal-close {
  background: none; border: none; color: #8b949e;
  font-size: 1.1rem; cursor: pointer; padding: 2px 6px;
  transition: color 0.15s;
}
.modal-close:hover { color: #e6edf3; }
.modal-list {
  max-height: 400px; overflow-y: auto;
  border: 1px solid #21262d; border-radius: 10px;
  user-select: text;
}
.push-item {
  display: flex; gap: 16px; align-items: baseline;
  padding: 11px 16px; border-bottom: 1px solid #21262d;
  font-size: 0.86rem;
}
.push-item:last-child { border-bottom: none; }
.push-item .push-label {
  flex: 0 0 180px; color: #8b949e; font-weight: 600;
}
.push-item .push-value {
  flex: 1; color: #e6edf3;
  font-family: 'Consolas', 'Courier New', monospace; word-break: break-all;
}
.push-item .push-value.err { color: #ff6b6b; }
.modal-value {
  max-height: 400px; overflow-y: auto; user-select: text;
  background: #0d1117; border: 1px solid #21262d; border-radius: 10px;
  padding: 14px 16px; color: #e6edf3;
  font-family: 'Consolas', 'Courier New', monospace; font-size: 0.86rem;
  white-space: pre-wrap; word-break: break-all;
}
.modal-value.err { color: #ff6b6b; }
.modal-dismiss {
  width: 100%; margin-top: 20px; padding: 12px;
  background: #1f2937; color: #e6edf3;
  border: 1px solid #374151; border-radius: 10px;
  font-size: 0.95rem; font-weight: 600; cursor: pointer;
  transition: background 0.15s;
}
.modal-dismiss:hover { background: #374151; }
