:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f1f5f9;
  color: #0f172a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(135deg, #eef2ff 0%, #f8fafc 45%, #ecfeff 100%);
  min-height: 100vh;
}

header {
  background: linear-gradient(135deg, #172554, #1d4ed8, #0891b2);
  color: white;
  padding: 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.22);
}

header h1 {
  margin: 0 0 5px;
  font-size: 26px;
}

header p {
  margin: 0;
  color: #dbeafe;
}

main {
  max-width: 1150px;
  margin: auto;
  padding: 22px;
}

section {
  margin-bottom: 30px;
}

h2 {
  color: #172554;
  margin-bottom: 14px;
}

.card {
  background: white;
  border-radius: 18px;
  padding: 18px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(245px, 1fr));
  gap: 16px;
}

.grid.small {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

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

.row h3 {
  margin: 0;
  color: #1e3a8a;
}

.badge {
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  background: #e2e8f0;
}

.badge.running {
  background: #dcfce7;
  color: #15803d;
}

.badge.stopped {
  background: #fee2e2;
  color: #b91c1c;
}

.badge.pending,
.badge.stopping,
.badge.shutting-down {
  background: #fef3c7;
  color: #b45309;
}

.actions {
  display: flex;
  gap: 9px;
  margin: 15px 0 10px;
}

button {
  border: 0;
  border-radius: 11px;
  padding: 11px 15px;
  font-weight: 750;
  cursor: pointer;
  transition: 0.2s;
  width: 100%;
}

button:hover {
  transform: translateY(-1px);
  opacity: 0.92;
}

.primary {
  background: #2563eb;
  color: white;
}

.danger {
  background: #dc2626;
  color: white;
}

.secondary {
  background: #0f766e;
  color: white;
  margin-top: 9px;
}

.ghost {
  background: rgba(255,255,255,.16);
  color: white;
  border: 1px solid rgba(255,255,255,.3);
  width: auto;
}

.alert {
  padding: 13px 16px;
  border-radius: 12px;
  margin-bottom: 16px;
  font-weight: 600;
}

.success {
  background: #dcfce7;
  color: #166534;
  border-left: 5px solid #22c55e;
}

.error {
  background: #fee2e2;
  color: #991b1b;
  border-left: 5px solid #ef4444;
}

.muted {
  color: #64748b;
  font-size: 14px;
}

.wifi {
  border: 1px solid #bfdbfe;
  background: linear-gradient(135deg, #eff6ff, #ecfeff);
  padding: 16px;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.wifi b {
  color: #1d4ed8;
  font-size: 17px;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-card {
  width: min(420px, 100%);
  border-top: 5px solid #2563eb;
}

.login-card h1 {
  color: #172554;
  margin-top: 0;
}

label {
  display: block;
  margin: 13px 0 6px;
  font-weight: 700;
}

input {
  width: 100%;
  padding: 12px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
}

.login-card button {
  margin-top: 17px;
}

@media (max-width: 600px) {
  header {
    align-items: flex-start;
    padding: 18px;
  }

  header h1 {
    font-size: 21px;
  }

  main {
    padding: 13px;
  }

  .card {
    padding: 15px;
  }

  .actions {
    flex-direction: column;
  }
}

.dns-box {
  margin-top: 14px;
  padding: 12px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

.dns-box p {
  margin: 5px 0;
  font-size: 14px;
}

.dns-ok {
  margin-top: 10px;
  padding: 9px 11px;
  border-radius: 9px;
  background: #dcfce7;
  color: #166534;
  font-weight: 700;
}

.dns-warning {
  margin-top: 10px;
  padding: 9px 11px;
  border-radius: 9px;
  background: #fef3c7;
  color: #92400e;
  font-weight: 700;
}


/* ---------- Security Group Update Results ---------- */

.sg-result {
  margin: 16px 0 20px;
  padding: 16px;
  border: 1px solid #d9e3ef;
  border-radius: 14px;
  background: #f8fbff;
}

.sg-result-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.sg-summary {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.sg-count {
  padding: 6px 9px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
}

.sg-count.updated {
  background: #dcfce7;
}

.sg-count.skipped {
  background: #eef2ff;
}

.sg-count.failed {
  background: #fee2e2;
}

.sg-count.not-found {
  background: #fef3c7;
}

.sg-server-results {
  display: grid;
  gap: 9px;
}

.sg-server {
  border: 1px solid #dbe4ef;
  border-radius: 10px;
  background: white;
  overflow: hidden;
}

.sg-server summary {
  cursor: pointer;
  padding: 12px 14px;
  font-weight: 700;
  color: #193b8f;
}

.server-summary {
  margin-left: 8px;
  font-size: 12px;
  color: #333;
}

.sg-port-list {
  border-top: 1px solid #e5e7eb;
}

.sg-port-row {
  display: grid;
  grid-template-columns: 80px 125px 1fr;
  gap: 8px;
  padding: 9px 14px;
  border-bottom: 1px solid #edf0f4;
  font-size: 13px;
}

.sg-port-row:last-child {
  border-bottom: 0;
}

.sg-port {
  font-weight: 700;
}

.sg-port-status {
  font-weight: 700;
}

.sg-port-message {
  overflow-wrap: anywhere;
  color: #555;
}

.sg-port-row.updated {
  background: #f0fdf4;
}

.sg-port-row.skipped {
  background: #f8fafc;
}

.sg-port-row.failed {
  background: #fef2f2;
}

.sg-port-row.not_found {
  background: #fffbeb;
}

@media (max-width: 650px) {

  .sg-port-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

}

/* Force EC2 Refresh Status button visible */
.instance-refresh {
    display: block !important;
    width: 100% !important;
    margin-top: 12px !important;
    padding: 10px 12px !important;
    background: #365d9d !important;
    color: white !important;
    border: none !important;
    border-radius: 8px !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.instance-refresh:hover {
    opacity: 0.9 !important;
}
